Skip to content

Commit fe372af

Browse files
committed
Commit before tidying up redundant files
1 parent 23ec381 commit fe372af

16 files changed

Lines changed: 3610 additions & 3049 deletions

File tree

Phaser/Game.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,9 @@ module Phaser {
639639
* @param context The context in which the callbacks will be called
640640
* @returns {boolean} true if the objects overlap, otherwise false.
641641
*/
642-
//public collide(objectOrGroup1 = null, objectOrGroup2 = null, notifyCallback = null, context? = this.callbackContext): bool {
643-
// return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Collision.separate, context);
644-
//}
642+
public collide(objectOrGroup1 = null, objectOrGroup2 = null, notifyCallback = null, context? = this.callbackContext): bool {
643+
return this.world.physics.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, this.world.physics.separate, context);
644+
}
645645

646646
public get camera(): Camera {
647647
return this.world.cameras.current;

Phaser/Phaser.csproj

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,21 @@
121121
</Content>
122122
<TypeScriptCompile Include="physics\IPhysicsShape.ts" />
123123
<TypeScriptCompile Include="physics\Circle.ts" />
124+
<TypeScriptCompile Include="physics\Body.ts" />
125+
<Content Include="physics\Body.js">
126+
<DependentUpon>Body.ts</DependentUpon>
127+
</Content>
124128
<Content Include="physics\Circle.js">
125129
<DependentUpon>Circle.ts</DependentUpon>
126130
</Content>
131+
<TypeScriptCompile Include="physics\IPhysicsBody.ts" />
132+
<TypeScriptCompile Include="physics\Fixture.ts" />
133+
<Content Include="physics\Fixture.js">
134+
<DependentUpon>Fixture.ts</DependentUpon>
135+
</Content>
136+
<Content Include="physics\IPhysicsBody.js">
137+
<DependentUpon>IPhysicsBody.ts</DependentUpon>
138+
</Content>
127139
<Content Include="physics\IPhysicsShape.js">
128140
<DependentUpon>IPhysicsShape.ts</DependentUpon>
129141
</Content>
@@ -215,7 +227,7 @@
215227
<Content Include="math\LinkedList.js">
216228
<DependentUpon>LinkedList.ts</DependentUpon>
217229
</Content>
218-
<Content Include="math\QuadTree.js">
230+
<Content Include="physics\QuadTree.js">
219231
<DependentUpon>QuadTree.ts</DependentUpon>
220232
</Content>
221233
<Content Include="math\RandomDataGenerator.js">
@@ -234,7 +246,7 @@
234246
<TypeScriptCompile Include="system\StageScaleMode.ts" />
235247
<TypeScriptCompile Include="system\RequestAnimationFrame.ts" />
236248
<TypeScriptCompile Include="math\RandomDataGenerator.ts" />
237-
<TypeScriptCompile Include="math\QuadTree.ts" />
249+
<TypeScriptCompile Include="physics\QuadTree.ts" />
238250
<TypeScriptCompile Include="math\LinkedList.ts" />
239251
<TypeScriptCompile Include="system\Device.ts" />
240252
<TypeScriptCompile Include="cameras\Camera.ts" />

Phaser/Statics.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ module Phaser {
2424
static GEOM_LINE: number = 3;
2525
static GEOM_POLYGON: number = 4;
2626

27+
static BODY_DISABLED: number = 0;
28+
static BODY_DYNAMIC: number = 1;
29+
static BODY_STATIC: number = 2;
30+
static BODY_KINEMATIC: number = 3;
31+
2732
/**
2833
* Flag used to allow GameObjects to collide on their left side
2934
* @type {number}

Phaser/World.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ module Phaser {
3737

3838
this.physics = new Physics.PhysicsManager(this._game, width, height);
3939

40-
this.worldDivisions = 6;
41-
4240
}
4341

4442
/**
@@ -70,17 +68,13 @@ module Phaser {
7068
*/
7169
public physics: Physics.PhysicsManager;
7270

73-
/**
74-
* @type {number}
75-
*/
76-
public worldDivisions: number;
7771

7872
/**
7973
* This is called automatically every frame, and is where main logic happens.
8074
*/
8175
public update() {
8276

83-
this.physics.update();
77+
//this.physics.update();
8478
this.group.update();
8579
this.cameras.update();
8680

Phaser/components/sprite/Physics.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
/// <reference path="../../physics/AABB.ts" />
55
/// <reference path="../../physics/Circle.ts" />
66
/// <reference path="../../physics/IPhysicsShape.ts" />
7+
/// <reference path="../../physics/IPhysicsBody.ts" />
78

89
/**
910
* Phaser - Components - Physics
1011
*/
1112

1213
module Phaser.Components {
1314

14-
export class Physics {
15+
export class Physics implements Phaser.Physics.IPhysicsBody {
1516

1617
constructor(parent: Sprite) {
1718

@@ -50,7 +51,6 @@ module Phaser.Components {
5051
* @type {boolean}
5152
*/
5253
public moves: bool = true;
53-
public mass: number = 1;
5454

5555
public gravity: Vec2;
5656
public drag: Vec2;
@@ -62,9 +62,11 @@ module Phaser.Components {
6262
public touching: number;
6363
public allowCollisions: number;
6464
public wasTouching: number;
65+
public mass: number = 1;
6566

6667
public setCircle(diameter: number) {
6768

69+
// Here is the stuff I want to remove
6870
this.game.world.physics.remove(this.shape);
6971
this.shape = this.game.world.physics.add(new Phaser.Physics.Circle(this.game, this._sprite, this._sprite.x, this._sprite.y, diameter));
7072
this._sprite.physics.shape.physics = this;
@@ -76,6 +78,7 @@ module Phaser.Components {
7678
*/
7779
public update() {
7880

81+
// if this is all it does maybe move elsewhere? Sprite postUpdate?
7982
if (this.moves && this.shape)
8083
{
8184
this._sprite.x = (this.shape.position.x - this.shape.bounds.halfWidth) - this.shape.offset.x;

Phaser/core/Group.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ module Phaser {
153153
* Calls update on all members of this Group who have a status of active=true and exists=true
154154
* You can also call Object.update directly, which will bypass the active/exists check.
155155
*/
156-
public update(forceUpdate?: bool = false) {
156+
public update() {
157157

158158
this._i = 0;
159159

@@ -164,7 +164,7 @@ module Phaser {
164164
if (this._member != null && this._member.exists && this._member.active)
165165
{
166166
this._member.preUpdate();
167-
this._member.update(forceUpdate);
167+
this._member.update();
168168
this._member.postUpdate();
169169
}
170170
}

Phaser/gameobjects/GameObjectFactory.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ module Phaser {
6262
*
6363
* @param x {number} X position of the new sprite.
6464
* @param y {number} Y position of the new sprite.
65-
* @param key {string} Optional, key for the sprite sheet you want it to use.
65+
* @param [key] {string} The image key as defined in the Game.Cache to use as the texture for this sprite
66+
* @param [bodyType] {number} The physics body type of the object (defaults to BODY_DISABLED)
6667
* @returns {Sprite} The newly created sprite object.
6768
*/
68-
public sprite(x: number, y: number, key?: string = ''): Sprite {
69-
return <Sprite> this._world.group.add(new Sprite(this._game, x, y, key));
69+
public sprite(x: number, y: number, key?: string = '', bodyType?: number = Phaser.Types.BODY_DISABLED): Sprite {
70+
return <Sprite> this._world.group.add(new Sprite(this._game, x, y, key, bodyType));
7071
}
7172

7273
/**
@@ -90,18 +91,6 @@ module Phaser {
9091
return <Group> this._world.group.add(new Group(this._game, maxSize));
9192
}
9293

93-
/**
94-
* Create a new Sprite with specific position and sprite sheet key.
95-
*
96-
* @param x {number} X position of the new sprite.
97-
* @param y {number} Y position of the new sprite.
98-
* @param key {string} Optional, key for the sprite sheet you want it to use.
99-
* @returns {Sprite} The newly created sprite object.
100-
* WILL NEED TO TRACK A SPRITE
101-
*/
102-
public physicsAABB(x: number, y: number, width: number, height: number): Physics.AABB {
103-
return <Physics.AABB> this._world.physics.add(new Physics.AABB(this._game, null, x, y, width, height));
104-
}
10594

10695
/**
10796
* Create a new Particle.

Phaser/gameobjects/Sprite.ts

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/// <reference path="../components/animation/AnimationManager.ts" />
55
/// <reference path="../components/sprite/Texture.ts" />
66
/// <reference path="../components/sprite/Physics.ts" />
7+
/// <reference path="../physics/Body.ts" />
78

89
/**
910
* Phaser - Sprite
@@ -21,10 +22,10 @@ module Phaser {
2122
* @param [x] {number} the initial x position of the sprite.
2223
* @param [y] {number} the initial y position of the sprite.
2324
* @param [key] {string} Key of the graphic you want to load for this sprite.
24-
* @param [width] {number} The width of the object.
25-
* @param [height] {number} The height of the object.
25+
* @param [bodyType] {number} The physics body type of the object (defaults to BODY_DISABLED)
2626
*/
27-
constructor(game: Game, x?: number = 0, y?: number = 0, key?: string = null, width?: number = 16, height?: number = 16) {
27+
//constructor(game: Game, x?: number = 0, y?: number = 0, key?: string = null, width?: number = 16, height?: number = 16) {
28+
constructor(game: Game, x?: number = 0, y?: number = 0, key?: string = null, bodyType?: number = Phaser.Types.BODY_DISABLED) {
2829

2930
this.game = game;
3031
this.type = Phaser.Types.SPRITE;
@@ -35,7 +36,8 @@ module Phaser {
3536
this.visible = true;
3637
this.alive = true;
3738

38-
this.frameBounds = new Rectangle(x, y, width, height);
39+
// We give it a default size of 16x16 but when the texture loads (if given) it will reset this
40+
this.frameBounds = new Rectangle(x, y, 16, 16);
3941
this.scrollFactor = new Phaser.Vec2(1, 1);
4042

4143
this.x = x;
@@ -50,17 +52,11 @@ module Phaser {
5052
this.scale = new Phaser.Vec2(1, 1);
5153
this.skew = new Phaser.Vec2(0, 0);
5254

53-
this.physics = new Phaser.Components.Physics(this);
54-
this.physics.shape.physics = this.physics;
55+
// If a texture has been given the body will be set to that size, otherwise 16x16
56+
this.body = new Phaser.Physics.Body(this, bodyType);
5557

5658
}
5759

58-
/**
59-
* Rotation angle of this object.
60-
* @type {number}
61-
*/
62-
private _rotation: number = 0;
63-
6460
/**
6561
* Reference to the main game object
6662
*/
@@ -97,9 +93,9 @@ module Phaser {
9793
public alive: bool;
9894

9995
/**
100-
* Sprite physics.
96+
* Sprite physics body.
10197
*/
102-
public physics: Phaser.Components.Physics;
98+
public body: Phaser.Physics.Body;
10399

104100
/**
105101
* The texture used to render the Sprite.
@@ -160,26 +156,26 @@ module Phaser {
160156
public z: number = 0;
161157

162158
/**
163-
* This value is added to the rotation of the Sprite.
159+
* This value is added to the angle of the Sprite.
164160
* For example if you had a sprite graphic drawn facing straight up then you could set
165-
* rotationOffset to 90 and it would correspond correctly with Phasers right-handed coordinate system.
161+
* angleOffset to 90 and it would correspond correctly with Phasers right-handed coordinate system.
166162
* @type {number}
167163
*/
168-
public rotationOffset: number = 0;
164+
public angleOffset: number = 0;
169165

170166
/**
171-
* The rotation of the sprite in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
167+
* The angle of the sprite in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
172168
*/
173-
public get rotation(): number {
174-
return this._rotation;
169+
public get angle(): number {
170+
return this.body.angle;
175171
}
176172

177173
/**
178-
* Set the rotation of the sprite in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
174+
* Set the angle of the sprite in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
179175
* The value is automatically wrapped to be between 0 and 360.
180176
*/
181-
public set rotation(value: number) {
182-
this._rotation = this.game.math.wrap(value, 360, 0);
177+
public set angle(value: number) {
178+
this.body.angle = this.game.math.wrap(value, 360, 0);
183179
}
184180

185181
/**
@@ -234,7 +230,7 @@ module Phaser {
234230
this.frameBounds.x = this.x;
235231
this.frameBounds.y = this.y;
236232

237-
if (this.modified == false && (!this.scale.equals(1) || !this.skew.equals(0) || this.rotation != 0 || this.rotationOffset != 0 || this.texture.flippedX || this.texture.flippedY))
233+
if (this.modified == false && (!this.scale.equals(1) || !this.skew.equals(0) || this.angle != 0 || this.angleOffset != 0 || this.texture.flippedX || this.texture.flippedY))
238234
{
239235
this.modified = true;
240236
}
@@ -253,7 +249,7 @@ module Phaser {
253249
public postUpdate() {
254250

255251
this.animations.update();
256-
this.physics.update();
252+
this.body.postUpdate();
257253

258254
/*
259255
if (this.worldBounds != null)
@@ -287,15 +283,11 @@ module Phaser {
287283
}
288284
}
289285
290-
this.collisionMask.update();
291-
292286
if (this.inputEnabled)
293287
{
294288
this.updateInput();
295289
}
296290
297-
this.wasTouching = this.touching;
298-
this.touching = Collision.NONE;
299291
*/
300292

301293
if (this.modified == true && this.scale.equals(1) && this.skew.equals(0) && this.rotation == 0 && this.rotationOffset == 0 && this.texture.flippedX == false && this.texture.flippedY == false)

0 commit comments

Comments
 (0)