@@ -17,15 +17,16 @@ module Phaser.Components {
1717 this . _game = parent . game ;
1818 this . _sprite = parent ;
1919
20- this . gravityFactor = new Vec2 ( 1 , 1 ) ;
21- this . drag = new Vec2 ( 0 , 0 ) ;
22- this . bounce = new Vec2 ( 0 , 0 ) ;
23- this . friction = new Vec2 ( 0.05 , 0.05 ) ;
24- this . velocity = new Vec2 ( 0 , 0 ) ;
25- this . acceleration = new Vec2 ( 0 , 0 ) ;
20+ // Copy from PhysicsManager?
21+ this . gravity = new Vec2 ;
22+ this . drag = new Vec2 ;
23+ this . bounce = new Vec2 ;
24+ this . friction = new Vec2 ;
25+ this . velocity = new Vec2 ;
26+ this . acceleration = new Vec2 ;
2627
2728 //this.AABB = new Phaser.Physics.AABB(this._game, this._sprite, this._sprite.x, this._sprite.y, this._sprite.width, this._sprite.height);
28- this . AABB = 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 ) ) ;
29+ 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 ) ) ;
2930
3031 }
3132
@@ -39,7 +40,7 @@ module Phaser.Components {
3940 */
4041 private _sprite : Sprite ;
4142
42- public AABB : Phaser . Physics . AABB ;
43+ public shape : Phaser . Physics . IPhysicsShape ;
4344
4445 /**
4546 * Whether this object will be moved by impacts with other objects or not.
@@ -53,25 +54,26 @@ module Phaser.Components {
5354 */
5455 public moves : bool = true ;
5556
56- public gravityFactor : Vec2 ;
57+ public gravity : Vec2 ;
5758 public drag : Vec2 ;
5859 public bounce : Vec2 ;
5960 public friction : Vec2 ;
6061 public velocity : Vec2 ;
6162 public acceleration : Vec2 ;
6263
63-
6464 /**
6565 * Internal function for updating the position and speed of this object.
6666 */
6767 public update ( ) {
6868
6969 if ( this . moves )
7070 {
71- this . _sprite . x = this . AABB . position . x - this . AABB . halfWidth ;
72- this . _sprite . y = this . AABB . position . y - this . AABB . halfHeight ;
73- //this._sprite.x = this.AABB.position.x;
74- //this._sprite.y = this.AABB.position.y;
71+ this . _sprite . x = ( this . shape . position . x - this . shape . bounds . halfWidth ) - this . shape . offset . x ;
72+ this . _sprite . y = ( this . shape . position . y - this . shape . bounds . halfHeight ) - this . shape . offset . y ;
73+ //this._sprite.x = (this.shape.position.x - this.shape.bounds.halfWidth);
74+ //this._sprite.y = (this.shape.position.y - this.shape.bounds.halfHeight);
75+ //this._sprite.x = (this.shape.position.x);
76+ //this._sprite.y = (this.shape.position.y);
7577 }
7678 }
7779
0 commit comments