@@ -47,9 +47,6 @@ module Phaser.Physics {
4747 public scale : Vec2 ;
4848 public bounds : Rectangle ;
4949
50- public oH : number ;
51- public oV : number ;
52-
5350 public preUpdate ( ) {
5451
5552 this . oldPosition . copyFrom ( this . position ) ;
@@ -88,12 +85,6 @@ module Phaser.Physics {
8885
8986 public render ( context :CanvasRenderingContext2D ) {
9087
91- //context.beginPath();
92- //context.strokeStyle = 'rgb(255,255,0)';
93- //context.strokeRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height);
94- //context.stroke();
95- //context.closePath();
96-
9788 context . beginPath ( ) ;
9889 context . strokeStyle = 'rgb(0,255,0)' ;
9990 context . strokeRect ( this . position . x - this . bounds . halfWidth , this . position . y - this . bounds . halfHeight , this . bounds . width , this . bounds . height ) ;
@@ -104,7 +95,7 @@ module Phaser.Physics {
10495 context . fillStyle = 'rgb(0,255,0)' ;
10596 context . fillRect ( this . position . x , this . position . y , 2 , 2 ) ;
10697
107- if ( this . physics . touching == Phaser . Types . LEFT )
98+ if ( this . physics . touching & Phaser . Types . LEFT )
10899 {
109100 context . beginPath ( ) ;
110101 context . strokeStyle = 'rgb(255,0,0)' ;
@@ -113,7 +104,7 @@ module Phaser.Physics {
113104 context . stroke ( ) ;
114105 context . closePath ( ) ;
115106 }
116- else if ( this . physics . touching == Phaser . Types . RIGHT )
107+ if ( this . physics . touching & Phaser . Types . RIGHT )
117108 {
118109 context . beginPath ( ) ;
119110 context . strokeStyle = 'rgb(255,0,0)' ;
@@ -123,7 +114,7 @@ module Phaser.Physics {
123114 context . closePath ( ) ;
124115 }
125116
126- if ( this . physics . touching == Phaser . Types . UP )
117+ if ( this . physics . touching & Phaser . Types . UP )
127118 {
128119 context . beginPath ( ) ;
129120 context . strokeStyle = 'rgb(255,0,0)' ;
@@ -132,7 +123,7 @@ module Phaser.Physics {
132123 context . stroke ( ) ;
133124 context . closePath ( ) ;
134125 }
135- else if ( this . physics . touching == Phaser . Types . DOWN )
126+ if ( this . physics . touching & Phaser . Types . DOWN )
136127 {
137128 context . beginPath ( ) ;
138129 context . strokeStyle = 'rgb(255,0,0)' ;
@@ -144,6 +135,74 @@ module Phaser.Physics {
144135
145136 }
146137
138+ public get hullWidth ( ) : number {
139+
140+ if ( this . deltaX > 0 )
141+ {
142+ return this . bounds . width + this . deltaX ;
143+ }
144+ else
145+ {
146+ return this . bounds . width - this . deltaX ;
147+ }
148+
149+ }
150+
151+ public get hullHeight ( ) : number {
152+
153+ if ( this . deltaY > 0 )
154+ {
155+ return this . bounds . height + this . deltaY ;
156+ }
157+ else
158+ {
159+ return this . bounds . height - this . deltaY ;
160+ }
161+
162+ }
163+
164+ public get hullX ( ) : number {
165+
166+ if ( this . position . x < this . oldPosition . x )
167+ {
168+ return this . position . x ;
169+ }
170+ else
171+ {
172+ return this . oldPosition . x ;
173+ }
174+
175+ }
176+
177+ public get hullY ( ) : number {
178+
179+ if ( this . position . y < this . oldPosition . y )
180+ {
181+ return this . position . y ;
182+ }
183+ else
184+ {
185+ return this . oldPosition . y ;
186+ }
187+
188+ }
189+
190+ public get deltaXAbs ( ) : number {
191+ return ( this . deltaX > 0 ? this . deltaX : - this . deltaX ) ;
192+ }
193+
194+ public get deltaYAbs ( ) : number {
195+ return ( this . deltaY > 0 ? this . deltaY : - this . deltaY ) ;
196+ }
197+
198+ public get deltaX ( ) : number {
199+ return this . position . x - this . oldPosition . x ;
200+ }
201+
202+ public get deltaY ( ) : number {
203+ return this . position . y - this . oldPosition . y ;
204+ }
205+
147206 }
148207
149208}
0 commit comments