Skip to content

Commit 80f5c0a

Browse files
committed
Merge branch 'photonstorm/097'
2 parents d848fa0 + 0a75132 commit 80f5c0a

34 files changed

Lines changed: 13614 additions & 52 deletions

Phaser/Phaser.csproj

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@
5656
<TypeScriptOutFile>../build/phaser.js</TypeScriptOutFile>
5757
<TypeScriptGeneratesDeclarations>true</TypeScriptGeneratesDeclarations>
5858
</PropertyGroup>
59-
<ItemGroup />
59+
<ItemGroup>
60+
<Folder Include="physics\arcade\" />
61+
</ItemGroup>
6062
<ItemGroup>
6163
<Content Include="components\animation\AnimationManager.js">
6264
<DependentUpon>AnimationManager.ts</DependentUpon>
@@ -161,12 +163,88 @@
161163
</Content>
162164
<TypeScriptCompile Include="Motion.ts" />
163165
<TypeScriptCompile Include="math\Vec2.ts" />
166+
<TypeScriptCompile Include="math\Transform.ts" />
167+
<Content Include="math\Transform.js">
168+
<DependentUpon>Transform.ts</DependentUpon>
169+
</Content>
170+
<TypeScriptCompile Include="math\TransformUtils.ts" />
171+
<Content Include="math\TransformUtils.js">
172+
<DependentUpon>TransformUtils.ts</DependentUpon>
173+
</Content>
164174
<Content Include="math\Vec2.js">
165175
<DependentUpon>Vec2.ts</DependentUpon>
166176
</Content>
167177
<Content Include="Motion.js">
168178
<DependentUpon>Motion.ts</DependentUpon>
169179
</Content>
180+
<TypeScriptCompile Include="physics\ArcadePhysics.ts" />
181+
<TypeScriptCompile Include="physics\advanced\Body.ts" />
182+
<Content Include="physics\advanced\Body.js">
183+
<DependentUpon>Body.ts</DependentUpon>
184+
</Content>
185+
<TypeScriptCompile Include="physics\advanced\Bounds.ts" />
186+
<Content Include="physics\advanced\Bounds.js">
187+
<DependentUpon>Bounds.ts</DependentUpon>
188+
</Content>
189+
<TypeScriptCompile Include="physics\advanced\Contact.ts" />
190+
<TypeScriptCompile Include="physics\advanced\Collision.ts" />
191+
<Content Include="physics\advanced\Collision.js">
192+
<DependentUpon>Collision.ts</DependentUpon>
193+
</Content>
194+
<Content Include="physics\advanced\Contact.js">
195+
<DependentUpon>Contact.ts</DependentUpon>
196+
</Content>
197+
<TypeScriptCompile Include="physics\advanced\ContactSolver.ts" />
198+
<Content Include="physics\advanced\ContactSolver.js">
199+
<DependentUpon>ContactSolver.ts</DependentUpon>
200+
</Content>
201+
<TypeScriptCompile Include="physics\advanced\Manager.ts" />
202+
<TypeScriptCompile Include="physics\advanced\joints\IJoint.ts" />
203+
<Content Include="physics\advanced\joints\IJoint.js">
204+
<DependentUpon>IJoint.ts</DependentUpon>
205+
</Content>
206+
<TypeScriptCompile Include="physics\advanced\joints\Joint.ts" />
207+
<Content Include="physics\advanced\joints\Joint.js">
208+
<DependentUpon>Joint.ts</DependentUpon>
209+
</Content>
210+
<Content Include="physics\advanced\Manager.js">
211+
<DependentUpon>Manager.ts</DependentUpon>
212+
</Content>
213+
<TypeScriptCompile Include="physics\advanced\shapes\Shape.ts" />
214+
<TypeScriptCompile Include="physics\advanced\shapes\IShape.ts" />
215+
<TypeScriptCompile Include="physics\advanced\shapes\Box.ts" />
216+
<Content Include="physics\advanced\shapes\Box.js">
217+
<DependentUpon>Box.ts</DependentUpon>
218+
</Content>
219+
<TypeScriptCompile Include="physics\advanced\shapes\Circle.ts" />
220+
<Content Include="physics\advanced\shapes\Circle.js">
221+
<DependentUpon>Circle.ts</DependentUpon>
222+
</Content>
223+
<Content Include="physics\advanced\shapes\IShape.js">
224+
<DependentUpon>IShape.ts</DependentUpon>
225+
</Content>
226+
<TypeScriptCompile Include="physics\advanced\shapes\Poly.ts" />
227+
<Content Include="physics\advanced\shapes\Poly.js">
228+
<DependentUpon>Poly.ts</DependentUpon>
229+
</Content>
230+
<TypeScriptCompile Include="physics\advanced\shapes\Segment.ts" />
231+
<Content Include="physics\advanced\shapes\Segment.js">
232+
<DependentUpon>Segment.ts</DependentUpon>
233+
</Content>
234+
<Content Include="physics\advanced\shapes\Shape.js">
235+
<DependentUpon>Shape.ts</DependentUpon>
236+
</Content>
237+
<TypeScriptCompile Include="physics\advanced\shapes\Triangle.ts" />
238+
<Content Include="physics\advanced\shapes\Triangle.js">
239+
<DependentUpon>Triangle.ts</DependentUpon>
240+
</Content>
241+
<TypeScriptCompile Include="physics\advanced\Space.ts" />
242+
<Content Include="physics\advanced\Space.js">
243+
<DependentUpon>Space.ts</DependentUpon>
244+
</Content>
245+
<Content Include="physics\ArcadePhysics.js">
246+
<DependentUpon>ArcadePhysics.ts</DependentUpon>
247+
</Content>
170248
<Content Include="physics\Body.js">
171249
<DependentUpon>Body.ts</DependentUpon>
172250
</Content>

Phaser/Statics.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ module Phaser {
2525
static GEOM_POLYGON: number = 4;
2626

2727
static BODY_DISABLED: number = 0;
28-
static BODY_DYNAMIC: number = 1;
29-
static BODY_STATIC: number = 2;
30-
static BODY_KINEMATIC: number = 3;
28+
static BODY_STATIC: number = 1;
29+
static BODY_KINETIC: number = 2;
30+
static BODY_DYNAMIC: number = 3;
3131

3232
/**
3333
* Flag used to allow GameObjects to collide on their left side

Phaser/World.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module Phaser {
7575
}
7676

7777
/**
78-
* Called one by Game during the boot process.
78+
* Called once by Game during the boot process.
7979
*/
8080
public boot() {
8181

Phaser/core/Group.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,6 @@ module Phaser {
623623
this.sort();
624624

625625
// What's the z index of the top most child?
626-
var tempZ: number = child.z;
627626
var childIndex: number = this._zCounter;
628627

629628
this._i = 0;
@@ -632,17 +631,21 @@ module Phaser {
632631
{
633632
this._member = this.members[this._i++];
634633

635-
if (this._i > childIndex)
634+
if (this._member)
636635
{
637-
this._member.z--;
638-
}
639-
else if (this._member.z == child.z)
640-
{
641-
childIndex = this._i;
642-
this._member.z = this._zCounter;
636+
if (this._i > childIndex)
637+
{
638+
this._member.z--;
639+
}
640+
else if (this._member.z == child.z)
641+
{
642+
childIndex = this._i;
643+
this._member.z = this._zCounter;
644+
}
643645
}
644646
}
645647

648+
// Maybe redundant?
646649
this.sort();
647650

648651
return true;

Phaser/math/Transform.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/// <reference path="../Game.ts" />
2+
/// <reference path="Vec2Utils.ts" />
3+
4+
/**
5+
* Phaser - 2D Transform
6+
*
7+
* A 2D Transform
8+
*/
9+
10+
module Phaser {
11+
12+
export class Transform {
13+
14+
/**
15+
* Creates a new 2D Transform object.
16+
* @class Transform
17+
* @constructor
18+
* @return {Transform} This object
19+
**/
20+
constructor(pos: Phaser.Vec2, angle: number) {
21+
22+
this.t = Phaser.Vec2Utils.clone(pos);
23+
this.c = Math.cos(angle);
24+
this.s = Math.sin(angle);
25+
26+
}
27+
28+
public t: Phaser.Vec2;
29+
public c: number;
30+
public s: number;
31+
32+
public setTo(pos:Phaser.Vec2, angle:number) {
33+
34+
this.t.copyFrom(pos);
35+
this.c = Math.cos(angle);
36+
this.s = Math.sin(angle);
37+
38+
return this;
39+
40+
}
41+
42+
public setRotation(angle:number) {
43+
44+
this.c = Math.cos(angle);
45+
this.s = Math.sin(angle);
46+
return this;
47+
48+
}
49+
50+
public setPosition(p:Phaser.Vec2) {
51+
52+
this.t.copyFrom(p);
53+
return this;
54+
55+
}
56+
57+
public identity() {
58+
59+
this.t.setTo(0, 0);
60+
this.c = 1;
61+
this.s = 0;
62+
63+
return this;
64+
65+
}
66+
67+
}
68+
69+
}

Phaser/math/TransformUtils.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/// <reference path="../Game.ts" />
2+
/// <reference path="Vec2.ts" />
3+
/// <reference path="Transform.ts" />
4+
5+
/**
6+
* Phaser - TransformUtils
7+
*
8+
* A collection of methods useful for manipulating and performing operations on 2D Transforms.
9+
*
10+
*/
11+
12+
module Phaser {
13+
14+
export class TransformUtils {
15+
16+
public static rotate(t: Transform, v:Phaser.Vec2, out?: Vec2 = new Vec2):Phaser.Vec2 {
17+
return out.setTo(v.x * t.c - v.y * t.s, v.x * t.s + v.y * t.c);
18+
}
19+
20+
public static unrotate(t: Transform, v:Phaser.Vec2, out?: Vec2 = new Vec2):Phaser.Vec2 {
21+
return out.setTo(v.x * t.c + v.y * t.s, -v.x * t.s + v.y * t.c);
22+
}
23+
24+
public static transform(t: Transform, v:Phaser.Vec2, out?: Vec2 = new Vec2):Phaser.Vec2 {
25+
return out.setTo(v.x * t.c - v.y * t.s + t.t.x, v.x * t.s + v.y * t.c + t.t.y);
26+
}
27+
28+
public static untransform(t: Transform, v:Phaser.Vec2, out?: Vec2 = new Vec2):Phaser.Vec2 {
29+
30+
var px = v.x - t.t.x;
31+
var py = v.y - t.t.y;
32+
33+
return out.setTo(px * t.c + py * t.s, -px * t.s + py * t.c);
34+
35+
}
36+
37+
}
38+
39+
}

Phaser/math/Vec2.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,20 @@ module Phaser {
137137
return (this.x * this.x) + (this.y * this.y);
138138
}
139139

140+
/**
141+
* Normalize this vector.
142+
*
143+
* @return {Vec2} This for chaining.
144+
*/
145+
public normalize(): Vec2 {
146+
147+
var inv = (this.x != 0 || this.y != 0) ? 1 / Math.sqrt(this.x * this.x + this.y * this.y) : 0;
148+
this.x *= inv;
149+
this.y *= inv;
150+
return this;
151+
152+
}
153+
140154
/**
141155
* The dot product of two 2D vectors.
142156
*
@@ -217,6 +231,21 @@ module Phaser {
217231

218232
}
219233

234+
/**
235+
* Adds the given vector to this vector then multiplies by the given scalar.
236+
*
237+
* @param {Vec2} a Reference to a source Vec2 object.
238+
* @param {number} scalar
239+
* @return {Vec2} This for chaining.
240+
*/
241+
public multiplyAddByScalar(a: Vec2, scalar: number): Vec2 {
242+
243+
this.x += a.x * scalar;
244+
this.y += a.y * scalar;
245+
return this;
246+
247+
}
248+
220249
/**
221250
* Divide this vector by the given scalar.
222251
*

0 commit comments

Comments
 (0)