ScrollZone back in under the new renderer with new demos

This commit is contained in:
Richard Davey
2013-05-30 05:34:35 +01:00
parent f2054f8a2a
commit ce1523585f
28 changed files with 1582 additions and 349 deletions
+9 -22
View File
@@ -1,11 +1,10 @@
/// <reference path="../../core/Vec2.ts" />
/// <reference path="../../core/Point.ts" />
/// <reference path="../../math/Vec2Utils.ts" />
/// <reference path="../../physics/AABB.ts" />
/**
* Phaser - Components - Physics
*
*
*/
module Phaser.Components {
@@ -14,32 +13,24 @@ module Phaser.Components {
constructor(parent: Sprite) {
this._game = parent.game;
this.game = parent.game;
this._sprite = parent;
// Copy from PhysicsManager?
this.gravity = new Vec2;
this.drag = new Vec2;
this.bounce = new Vec2;
this.friction = new Vec2;
this.gravity = Vec2Utils.clone(this.game.world.physics.gravity);
this.drag = Vec2Utils.clone(this.game.world.physics.drag);
this.bounce = Vec2Utils.clone(this.game.world.physics.bounce);
this.friction = Vec2Utils.clone(this.game.world.physics.friction);
this.velocity = new Vec2;
this.acceleration = new Vec2;
//this.AABB = new Phaser.Physics.AABB(this._game, this._sprite, this._sprite.x, this._sprite.y, this._sprite.width, this._sprite.height);
this.shape = this._game.world.physics.add(new Phaser.Physics.AABB(this._game, this._sprite, this._sprite.x, this._sprite.y, this._sprite.width, this._sprite.height));
this.shape = this.game.world.physics.add(new Phaser.Physics.AABB(this.game, this._sprite, this._sprite.x, this._sprite.y, this._sprite.width, this._sprite.height));
}
/**
*
*/
private _game: Game;
/**
*
*/
private _sprite: Sprite;
public game: Game;
public shape: Phaser.Physics.IPhysicsShape;
/**
@@ -70,10 +61,6 @@ module Phaser.Components {
{
this._sprite.x = (this.shape.position.x - this.shape.bounds.halfWidth) - this.shape.offset.x;
this._sprite.y = (this.shape.position.y - this.shape.bounds.halfHeight) - this.shape.offset.y;
//this._sprite.x = (this.shape.position.x - this.shape.bounds.halfWidth);
//this._sprite.y = (this.shape.position.y - this.shape.bounds.halfHeight);
//this._sprite.x = (this.shape.position.x);
//this._sprite.y = (this.shape.position.y);
}
}
+20 -12
View File
@@ -44,13 +44,13 @@ module Phaser.Components {
/**
* Reference to the Image stored in the Game.Cache that is used as the texture for the Sprite.
*/
private _imageTexture = null;
public imageTexture = null;
/**
* Reference to the DynamicTexture that is used as the texture for the Sprite.
* @type {DynamicTexture}
*/
private _dynamicTexture: DynamicTexture = null;
public dynamicTexture: DynamicTexture = null;
/**
* The status of the texture image.
@@ -105,6 +105,12 @@ module Phaser.Components {
*/
public flippedY: bool = false;
/**
* Is the texture a DynamicTexture?
* @type {boolean}
*/
public isDynamic: bool = false;
/**
* Updates the texture being used to render the Sprite.
* Called automatically by SpriteUtils.loadTexture and SpriteUtils.loadDynamicTexture.
@@ -113,13 +119,15 @@ module Phaser.Components {
if (dynamic)
{
this._dynamicTexture = dynamic;
this.texture = this._dynamicTexture.canvas;
this.isDynamic = true;
this.dynamicTexture = dynamic;
this.texture = this.dynamicTexture.canvas;
}
else
{
this._imageTexture = image;
this.texture = this._imageTexture;
this.isDynamic = false;
this.imageTexture = image;
this.texture = this.imageTexture;
}
this.loaded = true;
@@ -183,13 +191,13 @@ module Phaser.Components {
*/
public get width(): number {
if (this._dynamicTexture)
if (this.isDynamic)
{
return this._dynamicTexture.width;
return this.dynamicTexture.width;
}
else
{
return this._imageTexture.width;
return this.imageTexture.width;
}
}
@@ -199,13 +207,13 @@ module Phaser.Components {
*/
public get height(): number {
if (this._dynamicTexture)
if (this.isDynamic)
{
return this._dynamicTexture.height;
return this.dynamicTexture.height;
}
else
{
return this._imageTexture.height;
return this.imageTexture.height;
}
}