1 goog.provide('lime.animation.RotateTo'); 2 3 4 goog.require('lime.Sprite'); 5 goog.require('lime.animation.Animation'); 6 7 /** 8 * Rotate to given angle in degrees 9 * @constructor 10 * @param {number} angle Target rotation value. 11 * @extends lime.animation.Animation 12 */ 13 lime.animation.RotateTo = function(angle) { 14 lime.animation.Animation.call(this); 15 16 this.angle_ = angle; 17 18 }; 19 goog.inherits(lime.animation.RotateTo, lime.animation.Animation); 20 21 /** 22 * @inheritDoc 23 */ 24 lime.animation.RotateTo.prototype.scope = 'rotate'; 25 26 /** 27 * @inheritDoc 28 * @see lime.animation.Animation#makeTargetProp 29 */ 30 lime.animation.RotateTo.prototype.makeTargetProp = function(target) { 31 var rot = target.getRotation(); 32 if (this.useTransitions()) { 33 target.addTransition(lime.Transition.ROTATION, 34 this.angle_, 35 this.duration_, this.getEasing() 36 ); 37 target.setDirty(lime.Dirty.POSITION); 38 } 39 return {startRot: rot, delta: this.angle_ - rot }; 40 }; 41 42 /** 43 * @inheritDoc 44 * @see lime.animation.Animation#update 45 */ 46 lime.animation.RotateTo.prototype.update = function(t, target) { 47 if (this.status_ == 0) return; 48 var prop = this.getTargetProp(target); 49 target.setRotation(prop.startRot + prop.delta * t); 50 }; 51 52 /** 53 * @inheritDoc 54 * @see lime.animation.Animation#clearTransition 55 */ 56 lime.animation.RotateTo.prototype.clearTransition = function(target) { 57 if (this.useTransitions()) { 58 target.clearTransition(lime.Transition.ROTATION); 59 target.setDirty(lime.Dirty.POSITION); 60 } 61 }; 62