Skip to content

Commit 05cc32f

Browse files
committed
Added final logo and start of CollisionMask
1 parent 53aa435 commit 05cc32f

11 files changed

Lines changed: 243 additions & 8 deletions

File tree

Docs/logo/phaser vector final.eps

125 KB
Binary file not shown.

Docs/logo/phaser vector final.fla

1.99 MB
Binary file not shown.

Docs/logo/phaser vector final.png

130 KB
Loading

Phaser/Phaser.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@
135135
<TypeScriptCompile Include="system\screens\BootScreen.ts" />
136136
<TypeScriptCompile Include="system\input\MSPointer.ts" />
137137
<TypeScriptCompile Include="system\input\Gestures.ts" />
138+
<TypeScriptCompile Include="system\CollisionMask.ts" />
139+
<Content Include="system\CollisionMask.js">
140+
<DependentUpon>CollisionMask.ts</DependentUpon>
141+
</Content>
138142
<Content Include="system\input\Gestures.js">
139143
<DependentUpon>Gestures.ts</DependentUpon>
140144
</Content>

Phaser/gameobjects/GeomSprite.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,10 @@ module Phaser {
228228
}
229229

230230
/**
231-
* Create a circle shape with specific diameter.
232-
* @param diameter {number} Diameter of the circle.
233-
* @return {GeomSprite} GeomSprite instance itself.
231+
* Create a rectangle shape of the given width and height size
232+
* @param width {Number} Width of the rectangle
233+
* @param height {Number} Height of the rectangle
234+
* @return {GeomSprite} GeomSprite instance.
234235
*/
235236
createRectangle(width: number, height: number): GeomSprite {
236237

Phaser/geom/Quad.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,30 @@ module Phaser {
9090

9191
}
9292

93+
/**
94+
* Copies the x/y/width/height values from the source object into this Quad
95+
* @method copyFrom
96+
* @param {Any} source The source object to copy from. Can be a Quad, Rectangle or any object with exposed x/y/width/height properties
97+
* @return {Quad} This object
98+
**/
99+
public copyFrom(source): Quad {
100+
101+
return this.setTo(source.x, source.y, source.width, source.height);
102+
103+
}
104+
105+
/**
106+
* Copies the x/y/width/height values from this Quad into the given target object
107+
* @method copyTo
108+
* @param {Any} target The object to copy this quads values in to. Can be a Quad, Rectangle or any object with exposed x/y/width/height properties
109+
* @return {Any} The target object
110+
**/
111+
public copyTo(target): any {
112+
113+
return target.copyFrom(this);
114+
115+
}
116+
93117
/**
94118
* Returns a string representation of this object.
95119
* @method toString

Phaser/system/CollisionMask.ts

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
/// <reference path="../Game.ts" />
2+
3+
/**
4+
* Phaser - CollisionMask
5+
*/
6+
7+
module Phaser {
8+
9+
export class CollisionMask {
10+
11+
/**
12+
* CollisionMask constructor. Creates a new <code>CollisionMask</code> for the given GameObject.
13+
*
14+
* @param game {Phaser.Game} Current game instance.
15+
* @param parent {Phaser.GameObject} The GameObject this CollisionMask belongs to.
16+
* @param x {number} The initial x position of the CollisionMask.
17+
* @param y {number} The initial y position of the CollisionMask.
18+
* @param width {number} The width of the CollisionMask.
19+
* @param height {number} The height of the CollisionMask.
20+
*/
21+
constructor(game: Game, parent: GameObject, x: number, y: number, width: number, height: number) {
22+
23+
this._game = game;
24+
this._parent = parent;
25+
26+
// By default the CollisionMask is a quad
27+
this.type = CollisionMask.QUAD;
28+
29+
this.quad = new Phaser.Quad(this._parent.x, this._parent.y, this._parent.width, this._parent.height);
30+
this.offset = new MicroPoint(0, 0);
31+
32+
return this;
33+
34+
}
35+
36+
private _game;
37+
private _parent;
38+
39+
/**
40+
* Geom type of this sprite. (available: UNASSIGNED, CIRCLE, LINE, POINT, RECTANGLE)
41+
* @type {number}
42+
*/
43+
public type: number = 0;
44+
45+
/**
46+
* Quad (a smaller version of Rectangle).
47+
* @type {number}
48+
*/
49+
public static QUAD: number = 0;
50+
51+
/**
52+
* Point.
53+
* @type {number}
54+
*/
55+
public static POINT: number = 1;
56+
57+
/**
58+
* Circle.
59+
* @type {number}
60+
*/
61+
public static CIRCLE: number = 2;
62+
63+
/**
64+
* Line.
65+
* @type {number}
66+
*/
67+
public static LINE: number = 3;
68+
69+
/**
70+
* Rectangle.
71+
* @type {number}
72+
*/
73+
public static RECTANGLE: number = 4;
74+
75+
/**
76+
* Polygon.
77+
* @type {number}
78+
*/
79+
public static POLYGON: number = 5;
80+
81+
/**
82+
* Rectangle shape container. A Rectangle instance.
83+
* @type {Rectangle}
84+
*/
85+
public quad: Quad;
86+
87+
/**
88+
* Point shape container. A Point instance.
89+
* @type {Point}
90+
*/
91+
public point: Point;
92+
93+
/**
94+
* Circle shape container. A Circle instance.
95+
* @type {Circle}
96+
*/
97+
public circle: Circle;
98+
99+
/**
100+
* Line shape container. A Line instance.
101+
* @type {Line}
102+
*/
103+
public line: Line;
104+
105+
/**
106+
* Rectangle shape container. A Rectangle instance.
107+
* @type {Rectangle}
108+
*/
109+
public rect: Rectangle;
110+
111+
/**
112+
* A value from the top-left of the GameObject frame that this collisionMask is offset to.
113+
* If the CollisionMask is a Quad/Rectangle the offset relates to the top-left of that Quad.
114+
* If the CollisionMask is a Circle the offset relates to the center of the circle.
115+
* @type {MicroPoint}
116+
*/
117+
public offset: MicroPoint;
118+
119+
120+
121+
public update() {
122+
123+
}
124+
125+
126+
127+
128+
129+
130+
131+
132+
133+
134+
135+
136+
/**
137+
* Destroy all objects and references belonging to this CollisionMask
138+
*/
139+
public destroy() {
140+
141+
this._game = null;
142+
this._parent = null;
143+
this.quad = null;
144+
this.point = null;
145+
this.circle = null;
146+
this.rect = null;
147+
this.line = null;
148+
this.offset = null;
149+
150+
}
151+
152+
153+
154+
155+
}
156+
157+
}

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ V0.9.6
8080
* Added Sprite.cacheKey which stores the key of the item from the cache that was used for its texture (if any)
8181
* Added GameMath.shuffleArray
8282
* Updated Animation.frame to return the index of the currentFrame if set
83+
* Added Quad.copyTo and Quad.copyFrom
8384

8485

8586

@@ -88,6 +89,10 @@ V0.9.6
8889
* TODO: Investigate bug re: tilemap collision and animation frames
8990
* TODO: Update tests that use arrow keys and include touch/mouse support
9091
* TODO: GameObject.clipRect
92+
* TODO: Use CollisionMask in Input instead of Circle?
93+
* TODO: Polygon geom primitive
94+
* TODO: Move GameObject transforms to a single matrix
95+
9196

9297

9398
Requirements

Tests/misc/starfield.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
}
2626
xxx = (xx[i]) / (zz[i]);
2727
yyy = (yy[i]) / (zz[i])--;
28-
var x = xxx + myGame.input.x;
29-
var y = yyy + myGame.input.y;
28+
//var x: number = xxx + myGame.input.x;
29+
//var y: number = yyy + myGame.input.y;
30+
var x = xxx + 400;
31+
var y = yyy + 300;
3032
var c = '#ffffff';
3133
if(zz[i] > 80) {
3234
c = '#666666';
@@ -35,7 +37,6 @@
3537
} else if(zz[i] > 40) {
3638
c = '#aaaaaa';
3739
}
38-
//else if (zz[i] > 20) c = '#ffffff';
3940
starfield.setPixel(x, y, c);
4041
}
4142
}

build/phaser.d.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,8 +1519,9 @@ module Phaser {
15191519
* @param frameRate {number} The speed in frames per second that the animation should play at (e.g. 60 fps).
15201520
* @param loop {boolean} Whether or not the animation is looped or just plays once.
15211521
* @param useNumericIndex {boolean} Use number indexes instead of string indexes?
1522+
* @return {Animation} The Animation that was created
15221523
*/
1523-
public add(name: string, frames?: any[], frameRate?: number, loop?: bool, useNumericIndex?: bool): void;
1524+
public add(name: string, frames?: any[], frameRate?: number, loop?: bool, useNumericIndex?: bool): Animation;
15241525
/**
15251526
* Check whether the frames is valid.
15261527
* @param frames {any[]} Frames to be validated.
@@ -8688,6 +8689,20 @@ module Phaser {
86888689
public destroy(): void;
86898690
}
86908691
}
8692+
interface IPoint {
8693+
getDist(): number;
8694+
}
8695+
module Shapes {
8696+
class Point implements IPoint {
8697+
public x: number;
8698+
public y: number;
8699+
constructor(x: number, y: number);
8700+
public getDist(): number;
8701+
static origin: Point;
8702+
}
8703+
}
8704+
var p: IPoint;
8705+
var dist: number;
86918706
/**
86928707
* Phaser - State
86938708
*

0 commit comments

Comments
 (0)