Added loop and yoyo properties to Tweens

This commit is contained in:
Richard Davey
2013-05-29 15:45:34 +01:00
parent b1d836dfaf
commit 7b4374cabf
30 changed files with 1624 additions and 703 deletions
+64 -5
View File
@@ -1,4 +1,5 @@
/// <reference path="../Game.ts" />
/// <reference path="../core/Vec2.ts" />
/// <reference path="../core/Rectangle.ts" />
/// <reference path="../components/animation/AnimationManager.ts" />
/// <reference path="../components/sprite/Texture.ts" />
@@ -34,19 +35,23 @@ module Phaser {
this.alive = true;
this.frameBounds = new Rectangle(x, y, width, height);
this.origin = new Phaser.Vec2(0, 0);
this.scrollFactor = new Phaser.Vec2(1, 1);
this.scale = new Phaser.Vec2(1, 1);
this.x = x;
this.y = y;
this.z = 0;
this.z = 0; // not used yet
this.texture = new Phaser.Components.Texture(this, key, game.stage.canvas, game.stage.context);
this.animations = new Phaser.Components.AnimationManager(this);
this.texture = new Phaser.Components.Texture(this, key);
this.width = this.frameBounds.width;
this.height = this.frameBounds.height;
// Transform related (if we add any more then move to a component)
this.origin = new Phaser.Vec2(this.width / 2, this.height / 2);
this.scale = new Phaser.Vec2(1, 1);
this.skew = new Phaser.Vec2(0, 0);
}
/**
@@ -99,6 +104,12 @@ module Phaser {
*/
public texture: Phaser.Components.Texture;
/**
* This manages animations of the sprite. You can modify animations though it. (see AnimationManager)
* @type AnimationManager
*/
public animations: Phaser.Components.AnimationManager;
/**
* The frame boundary around this Sprite.
* For non-animated sprites this matches the loaded texture dimensions.
@@ -111,6 +122,16 @@ module Phaser {
*/
public scale: Phaser.Vec2;
/**
* Skew the Sprite along the x and y axis. A skew value of 0 is no skew.
*/
public skew: Phaser.Vec2;
/**
* A boolean representing if the Sprite has been modified in any way via a scale, rotate, flip or skew.
*/
public modified: bool = false;
/**
* The influence of camera movement upon the Sprite.
*/
@@ -159,6 +180,34 @@ module Phaser {
this._rotation = this.game.math.wrap(value, 360, 0);
}
/**
* Set the animation frame by frame number.
*/
public set frame(value: number) {
this.animations.frame = value;
}
/**
* Get the animation frame number.
*/
public get frame(): number {
return this.animations.frame;
}
/**
* Set the animation frame by frame name.
*/
public set frameName(value: string) {
this.animations.frameName = value;
}
/**
* Get the animation frame name.
*/
public get frameName(): string {
return this.animations.frameName;
}
/**
* Pre-update is called right before update() on each object in the game loop.
*/
@@ -169,6 +218,11 @@ module Phaser {
//this.collisionMask.preUpdate();
if (this.modified == false && (!this.scale.equals(1) || !this.skew.equals(0) || this.rotation != 0 || this.rotationOffset != 0 || this.texture.flippedX || this.texture.flippedY))
{
this.modified = true;
}
}
/**
@@ -182,9 +236,9 @@ module Phaser {
*/
public postUpdate() {
/*
this.animations.update();
/*
if (this.moves)
{
this.updateMotion();
@@ -232,6 +286,11 @@ module Phaser {
this.touching = Collision.NONE;
*/
if (this.modified == true && this.scale.equals(1) && this.skew.equals(0) && this.rotation == 0 && this.rotationOffset == 0 && this.texture.flippedX == false && this.texture.flippedY == false)
{
this.modified = false;
}
}
/**