Skip to content

Commit 6648cb3

Browse files
committed
Merge branch 'photonstorm/097'
2 parents 80f5c0a + ec84515 commit 6648cb3

24 files changed

Lines changed: 1871 additions & 913 deletions

Phaser/Phaser.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@
213213
<TypeScriptCompile Include="physics\advanced\shapes\Shape.ts" />
214214
<TypeScriptCompile Include="physics\advanced\shapes\IShape.ts" />
215215
<TypeScriptCompile Include="physics\advanced\shapes\Box.ts" />
216+
<TypeScriptCompile Include="physics\advanced\Plane.ts" />
217+
<Content Include="physics\advanced\Plane.js">
218+
<DependentUpon>Plane.ts</DependentUpon>
219+
</Content>
216220
<Content Include="physics\advanced\shapes\Box.js">
217221
<DependentUpon>Box.ts</DependentUpon>
218222
</Content>

Phaser/input/Input.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,30 @@ module Phaser {
5353
this.activePointer = this.mousePointer;
5454
this.currentPointers = 0;
5555

56+
this.hitCanvas = <HTMLCanvasElement> document.createElement('canvas');
57+
this.hitCanvas.width = 1;
58+
this.hitCanvas.height = 1;
59+
this.hitContext = this.hitCanvas.getContext('2d');
60+
5661
}
5762

5863
/**
5964
* Local private reference to game.
6065
*/
6166
private _game: Game;
6267

68+
/**
69+
* A 1x1 sized canvas used for pixel-perfect checks
70+
* @type {HTMLCanvasElement}
71+
*/
72+
public hitCanvas: HTMLCanvasElement;
73+
74+
/**
75+
* The context of the 1x1 pixel check canvas
76+
* @type {CanvasRenderingContext2D}
77+
*/
78+
public hitContext: CanvasRenderingContext2D;
79+
6380
/**
6481
* A vector object representing the previous position of the Pointer.
6582
* @property vector
@@ -961,6 +978,14 @@ module Phaser {
961978
return Vec2Utils.angle(pointer1.position, pointer2.position);
962979
}
963980

981+
public pixelPerfectCheck(sprite: Phaser.Sprite, pointer: Phaser.Pointer, alpha: number = 255): bool {
982+
983+
this.hitContext.clearRect(0, 0, 1, 1);
984+
985+
return true;
986+
987+
}
988+
964989
}
965990

966991
}

Phaser/math/Transform.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,20 @@ module Phaser {
2222
this.t = Phaser.Vec2Utils.clone(pos);
2323
this.c = Math.cos(angle);
2424
this.s = Math.sin(angle);
25+
this.angle = angle;
2526

2627
}
2728

2829
public t: Phaser.Vec2;
2930
public c: number;
3031
public s: number;
32+
public angle: number;
33+
34+
public toString() {
35+
36+
return 't=' + this.t.toString() + ' c=' + this.c + ' s=' + this.s + ' a=' + this.angle;
37+
38+
}
3139

3240
public setTo(pos:Phaser.Vec2, angle:number) {
3341

@@ -41,15 +49,21 @@ module Phaser {
4149

4250
public setRotation(angle:number) {
4351

44-
this.c = Math.cos(angle);
45-
this.s = Math.sin(angle);
52+
if (angle !== this.angle)
53+
{
54+
this.c = Math.cos(angle);
55+
this.s = Math.sin(angle);
56+
this.angle = angle;
57+
}
58+
4659
return this;
4760

4861
}
4962

5063
public setPosition(p:Phaser.Vec2) {
5164

5265
this.t.copyFrom(p);
66+
5367
return this;
5468

5569
}

Phaser/math/TransformUtils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ module Phaser {
1414
export class TransformUtils {
1515

1616
public static rotate(t: Transform, v:Phaser.Vec2, out?: Vec2 = new Vec2):Phaser.Vec2 {
17+
//return new vec2(v.x * this.c - v.y * this.s, v.x * this.s + v.y * this.c);
1718
return out.setTo(v.x * t.c - v.y * t.s, v.x * t.s + v.y * t.c);
1819
}
1920

2021
public static unrotate(t: Transform, v:Phaser.Vec2, out?: Vec2 = new Vec2):Phaser.Vec2 {
22+
//return new vec2(v.x * this.c + v.y * this.s, -v.x * this.s + v.y * this.c);
2123
return out.setTo(v.x * t.c + v.y * t.s, -v.x * t.s + v.y * t.c);
2224
}
2325

2426
public static transform(t: Transform, v:Phaser.Vec2, out?: Vec2 = new Vec2):Phaser.Vec2 {
27+
//return new vec2(v.x * this.c - v.y * this.s + this.t.x, v.x * this.s + v.y * this.c + this.t.y);
2528
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);
2629
}
2730

@@ -30,6 +33,7 @@ module Phaser {
3033
var px = v.x - t.t.x;
3134
var py = v.y - t.t.y;
3235

36+
//return new vec2(px * this.c + py * this.s, -px * this.s + py * this.c);
3337
return out.setTo(px * t.c + py * t.s, -px * t.s + py * t.c);
3438

3539
}

Phaser/math/Vec2.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ module Phaser {
288288
* @return {string} a string representation of the object.
289289
**/
290290
public toString(): string {
291-
return "[{Vec2 (x=" + this.x + " y=" + this.y + ")}]";
291+
//return "[{Vec2 (x=" + this.x + " y=" + this.y + ")}]";
292+
return "x=" + this.x + " y=" + this.y;
292293
}
293294

294295
}

0 commit comments

Comments
 (0)