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