Skip to content

Commit 87e0c48

Browse files
committed
Version 0.9.1 release - see the release notes for more details.
1 parent d5229c5 commit 87e0c48

24 files changed

Lines changed: 2039 additions & 770 deletions

Phaser/Motion.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ module Phaser {
2020
private _game: Game;
2121

2222
/**
23-
* A tween-like function that takes a starting velocity
24-
* and some other factors and returns an altered velocity.
23+
* A tween-like function that takes a starting velocity and some other factors and returns an altered velocity.
2524
*
2625
* @param Velocity Any component of velocity (e.g. 20).
2726
* @param Acceleration Rate at which the velocity is changing.
@@ -385,7 +384,7 @@ module Phaser {
385384
public angleBetweenMouse(a:GameObject, asDegrees:bool = false):number
386385
{
387386
// In order to get the angle between the object and mouse, we need the objects screen coordinates (rather than world coordinates)
388-
var p:Point = a.getScreenXY();
387+
var p:MicroPoint = a.getScreenXY();
389388

390389
var dx:number = a._game.input.x - p.x;
391390
var dy:number = a._game.input.y - p.y;

Phaser/Phaser.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@
100100
<Content Include="geom\Line.js">
101101
<DependentUpon>Line.ts</DependentUpon>
102102
</Content>
103+
<TypeScriptCompile Include="geom\MicroPoint.ts" />
104+
<Content Include="geom\MicroPoint.js">
105+
<DependentUpon>MicroPoint.ts</DependentUpon>
106+
</Content>
103107
<Content Include="geom\Point.js">
104108
<DependentUpon>Point.ts</DependentUpon>
105109
</Content>

Phaser/Phaser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Phaser
33
*
4-
* v0.9 - April 18th 2013
4+
* v0.9.1 - April 19th 2013
55
*
66
* A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi.
77
*
@@ -16,6 +16,6 @@
1616

1717
module Phaser {
1818

19-
export var VERSION: string = 'Phaser version 0.9';
19+
export var VERSION: string = 'Phaser version 0.9.1';
2020

2121
}

Phaser/gameobjects/GameObject.ts

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ module Phaser {
2424
this.alive = true;
2525
this.isGroup = false;
2626
this.alpha = 1;
27-
this.scale = new Point(1, 1);
27+
this.scale = new MicroPoint(1, 1);
2828

29-
this.last = new Point(x, y);
30-
this.origin = new Point(this.bounds.halfWidth, this.bounds.halfHeight);
29+
this.last = new MicroPoint(x, y);
30+
this.origin = new MicroPoint(this.bounds.halfWidth, this.bounds.halfHeight);
31+
this.align = GameObject.ALIGN_TOP_LEFT;
3132
this.mass = 1.0;
3233
this.elasticity = 0.0;
3334
this.health = 1;
@@ -38,51 +39,69 @@ module Phaser {
3839
this.wasTouching = Collision.NONE;
3940
this.allowCollisions = Collision.ANY;
4041

41-
this.velocity = new Point();
42-
this.acceleration = new Point();
43-
this.drag = new Point();
44-
this.maxVelocity = new Point(10000, 10000);
42+
this.velocity = new MicroPoint();
43+
this.acceleration = new MicroPoint();
44+
this.drag = new MicroPoint();
45+
this.maxVelocity = new MicroPoint(10000, 10000);
4546

4647
this.angle = 0;
4748
this.angularVelocity = 0;
4849
this.angularAcceleration = 0;
4950
this.angularDrag = 0;
5051
this.maxAngular = 10000;
5152

52-
this.scrollFactor = new Point(1.0, 1.0);
53+
this.scrollFactor = new MicroPoint(1.0, 1.0);
5354

5455
}
5556

5657
private _angle: number = 0;
57-
public _point: Point;
58+
59+
public static ALIGN_TOP_LEFT: number = 0;
60+
public static ALIGN_TOP_CENTER: number = 1;
61+
public static ALIGN_TOP_RIGHT: number = 2;
62+
public static ALIGN_CENTER_LEFT: number = 3;
63+
public static ALIGN_CENTER: number = 4;
64+
public static ALIGN_CENTER_RIGHT: number = 5;
65+
public static ALIGN_BOTTOM_LEFT: number = 6;
66+
public static ALIGN_BOTTOM_CENTER: number = 7;
67+
public static ALIGN_BOTTOM_RIGHT: number = 8;
68+
69+
public _point: MicroPoint;
5870

5971
public bounds: Rectangle;
72+
public align: number;
6073
public facing: number;
6174
public alpha: number;
62-
public scale: Point;
63-
public origin: Point;
75+
public scale: MicroPoint;
76+
public origin: MicroPoint;
6477
public z: number = 0;
6578

6679
// Physics properties
6780
public immovable: bool;
68-
public velocity: Point;
81+
82+
// Velocity is given in pixels per second. Therefore a velocity of
83+
// 100 will move at a rate of 100 pixels every 1000 ms (1sec). It's not balls-on
84+
// accurate due to the way timers work, but it's pretty close. Expect tolerance
85+
// of +- 10 px. Also that speed assumes no drag
86+
public velocity: MicroPoint;
87+
6988
public mass: number;
7089
public elasticity: number;
71-
public acceleration: Point;
72-
public drag: Point;
73-
public maxVelocity: Point;
90+
public acceleration: MicroPoint;
91+
public drag: MicroPoint;
92+
public maxVelocity: MicroPoint;
7493
public angularVelocity: number;
7594
public angularAcceleration: number;
7695
public angularDrag: number;
7796
public maxAngular: number;
78-
public scrollFactor: Point;
97+
public scrollFactor: MicroPoint;
7998

8099
public health: number;
81100
public moves: bool = true;
82101
public touching: number;
83102
public wasTouching: number;
84103
public allowCollisions: number;
85-
public last: Point;
104+
public last: MicroPoint;
86105

87106
// Input
88107
public inputEnabled: bool = false;
@@ -123,9 +142,6 @@ module Phaser {
123142
}
124143

125144
private updateInput() {
126-
127-
128-
129145
}
130146

131147
private updateMotion() {
@@ -215,7 +231,7 @@ module Phaser {
215231

216232
/**
217233
* Checks to see if this <code>GameObject</code> were located at the given position, would it overlap the <code>GameObject</code> or <code>Group</code>?
218-
* This is distinct from overlapsPoint(), which just checks that ponumber, rather than taking the object's size numbero account.
234+
* This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size numbero account.
219235
* WARNING: Currently tilemaps do NOT support screen space overlap checks!
220236
*
221237
* @param X The X position you want to check. Pretends this object (the caller, not the parameter) is located here.
@@ -283,13 +299,13 @@ module Phaser {
283299
}
284300

285301
/**
286-
* Checks to see if a ponumber in 2D world space overlaps this <code>GameObject</code> object.
302+
* Checks to see if a point in 2D world space overlaps this <code>GameObject</code>.
287303
*
288-
* @param Point The ponumber in world space you want to check.
304+
* @param Point The point in world space you want to check.
289305
* @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap.
290306
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
291307
*
292-
* @return Whether or not the ponumber overlaps this object.
308+
* @return Whether or not the point overlaps this object.
293309
*/
294310
public overlapsPoint(point: Point, InScreenSpace: bool = false, Camera: Camera = null): bool {
295311

@@ -315,7 +331,7 @@ module Phaser {
315331
/**
316332
* Check and see if this object is currently on screen.
317333
*
318-
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
334+
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
319335
*
320336
* @return Whether the object is on screen or not.
321337
*/
@@ -336,15 +352,15 @@ module Phaser {
336352
* Call this to figure out the on-screen position of the object.
337353
*
338354
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
339-
* @param Point Takes a <code>Point</code> object and assigns the post-scrolled X and Y values of this object to it.
355+
* @param Point Takes a <code>MicroPoint</code> object and assigns the post-scrolled X and Y values of this object to it.
340356
*
341-
* @return The <code>Point</code> you passed in, or a new <code>Point</code> if you didn't pass one, containing the screen X and Y position of this object.
357+
* @return The <code>MicroPoint</code> you passed in, or a new <code>Point</code> if you didn't pass one, containing the screen X and Y position of this object.
342358
*/
343-
public getScreenXY(point: Point = null, Camera: Camera = null): Point {
359+
public getScreenXY(point: MicroPoint = null, Camera: Camera = null): MicroPoint {
344360

345361
if (point == null)
346362
{
347-
point = new Point();
363+
point = new MicroPoint();
348364
}
349365

350366
if (Camera == null)
@@ -387,21 +403,20 @@ module Phaser {
387403
}
388404

389405
/**
390-
* Retrieve the midponumber of this object in world coordinates.
406+
* Retrieve the midpoint of this object in world coordinates.
391407
*
392408
* @Point Allows you to pass in an existing <code>Point</code> object if you're so inclined. Otherwise a new one is created.
393409
*
394-
* @return A <code>Point</code> object containing the midponumber of this object in world coordinates.
410+
* @return A <code>Point</code> object containing the midpoint of this object in world coordinates.
395411
*/
396-
public getMidpoint(point: Point = null): Point {
412+
public getMidpoint(point: MicroPoint = null): MicroPoint {
397413

398414
if (point == null)
399415
{
400-
point = new Point();
416+
point = new MicroPoint();
401417
}
402418

403-
point.x = this.x + this.width * 0.5;
404-
point.y = this.y + this.height * 0.5;
419+
point.copyFrom(this.bounds.center);
405420

406421
return point;
407422

Phaser/gameobjects/GeomSprite.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ module Phaser {
182182
}
183183
else
184184
{
185-
return camera.overlap(this.bounds);
185+
return camera.intersects(this.bounds);
186186
}
187187

188188
}
@@ -221,7 +221,8 @@ module Phaser {
221221
this._dy -= (camera.worldView.y * this.scrollFactor.y);
222222
}
223223

224-
// Rotation (could be misleading as it doesn't work re: collision)
224+
// Rotation is disabled for now as I don't want it to be misleading re: collision
225+
/*
225226
if (this.angle !== 0)
226227
{
227228
this._game.stage.context.save();
@@ -230,6 +231,7 @@ module Phaser {
230231
this._dx = -(this._dw / 2);
231232
this._dy = -(this._dh / 2);
232233
}
234+
*/
233235

234236
this._dx = Math.round(this._dx);
235237
this._dy = Math.round(this._dy);
@@ -286,7 +288,6 @@ module Phaser {
286288
else
287289
{
288290
this._game.stage.context.beginPath();
289-
290291
this._game.stage.context.rect(this._dx, this._dy, this.rect.width, this.rect.height);
291292
this._game.stage.context.stroke();
292293

@@ -297,6 +298,19 @@ module Phaser {
297298

298299
this._game.stage.context.closePath();
299300
}
301+
302+
// And now the edge points
303+
this._game.stage.context.fillStyle = 'rgb(255,255,255)';
304+
this.renderPoint(this._dx, this._dy, this.rect.topLeft, 2);
305+
this.renderPoint(this._dx, this._dy, this.rect.topCenter, 2);
306+
this.renderPoint(this._dx, this._dy, this.rect.topRight, 2);
307+
this.renderPoint(this._dx, this._dy, this.rect.leftCenter, 2);
308+
this.renderPoint(this._dx, this._dy, this.rect.center, 2);
309+
this.renderPoint(this._dx, this._dy, this.rect.rightCenter, 2);
310+
this.renderPoint(this._dx, this._dy, this.rect.bottomLeft, 2);
311+
this.renderPoint(this._dx, this._dy, this.rect.bottomCenter, 2);
312+
this.renderPoint(this._dx, this._dy, this.rect.bottomRight, 2);
313+
300314
}
301315

302316
this._game.stage.restoreCanvasValues();
@@ -316,6 +330,14 @@ module Phaser {
316330

317331
}
318332

333+
public renderPoint(offsetX, offsetY, point, size) {
334+
335+
offsetX = 0;
336+
offsetY = 0;
337+
this._game.stage.context.fillRect(offsetX + point.x, offsetY + point.y, 1, 1);
338+
339+
}
340+
319341
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
320342

321343
//this._game.stage.context.fillStyle = color;

0 commit comments

Comments
 (0)