11/// <reference path="../../core/Vec2.ts" />
22/// <reference path="../../core/Point.ts" />
3+ /// <reference path="../../physics/AABB.ts" />
34
45/**
56* Phaser - Components - Physics
@@ -11,6 +12,28 @@ module Phaser.Components {
1112
1213 export class Physics {
1314
15+ constructor ( parent : Sprite ) {
16+
17+ this . _game = parent . game ;
18+ this . _sprite = parent ;
19+
20+ //this.AABB = new Phaser.Physics.AABB(this._game, this._sprite, this._sprite.x, this._sprite.y, this._sprite.width, this._sprite.height);
21+ 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 ) ) ;
22+
23+ }
24+
25+ /**
26+ *
27+ */
28+ private _game : Game ;
29+
30+ /**
31+ *
32+ */
33+ private _sprite : Sprite ;
34+
35+ public AABB : Phaser . Physics . AABB ;
36+
1437 /**
1538 * Whether this object will be moved by impacts with other objects or not.
1639 * @type {boolean }
@@ -126,9 +149,9 @@ module Phaser.Components {
126149 *
127150 * @return {boolean } Whether the object is touching an object in (any of) the specified direction(s) this frame.
128151 */
129- public isTouching ( direction : number ) : bool {
130- return ( this . touching & direction ) > Collision . NONE ;
131- }
152+ // public isTouching(direction: number): bool {
153+ // return (this.touching & direction) > Collision.NONE;
154+ // }
132155
133156 /**
134157 * Handy function for checking if this object just landed on a particular surface.
@@ -137,16 +160,22 @@ module Phaser.Components {
137160 *
138161 * @returns {boolean } Whether the object just landed on any specicied surfaces.
139162 */
140- public justTouched ( direction : number ) : bool {
141- return ( ( this . touching & direction ) > Collision . NONE ) && ( ( this . wasTouching & direction ) <= Collision . NONE ) ;
142- }
163+ // public justTouched(direction: number): bool {
164+ // return ((this.touching & direction) > Collision.NONE) && ((this.wasTouching & direction) <= Collision.NONE);
165+ // }
143166
144167
145168 /**
146169 * Internal function for updating the position and speed of this object.
147170 */
148171 public update ( ) {
149172
173+ if ( this . moves )
174+ {
175+ this . _sprite . x = this . AABB . position . x - this . AABB . halfWidth ;
176+ this . _sprite . y = this . AABB . position . y - this . AABB . halfHeight ;
177+ }
178+
150179/*
151180 var delta: number;
152181 var velocityDelta: number;
@@ -176,20 +205,20 @@ module Phaser.Components {
176205 * the object will collide from, use collision constants (like LEFT, FLOOR, etc)
177206 * to set the value of allowCollisions directly.
178207 */
179- public get solid ( ) : bool {
180- return ( this . allowCollisions & Collision . ANY ) > Collision . NONE ;
181- }
208+ // public get solid(): bool {
209+ // return (this.allowCollisions & Collision.ANY) > Collision.NONE;
210+ // }
182211
183212 public set solid ( value : bool ) {
184213
185- if ( value )
186- {
187- this . allowCollisions = Collision . ANY ;
188- }
189- else
190- {
191- this . allowCollisions = Collision . NONE ;
192- }
214+ // if (value)
215+ // {
216+ // this.allowCollisions = Collision.ANY;
217+ // }
218+ // else
219+ // {
220+ // this.allowCollisions = Collision.NONE;
221+ // }
193222
194223 }
195224
0 commit comments