Skip to content

Commit 0591c7f

Browse files
committed
Doing one final commit before the task of merging physics with core.
1 parent ec84515 commit 0591c7f

12 files changed

Lines changed: 657 additions & 680 deletions

File tree

Phaser/components/animation/FrameData.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,13 @@ module Phaser {
9393
*/
9494
public checkFrameName(name: string): bool {
9595

96-
if (this._frameNames[name])
96+
97+
if (this._frameNames[name] == null)
9798
{
98-
return true;
99+
return false;
99100
}
100101

101-
return false;
102+
return true;
102103

103104
}
104105

Phaser/components/sprite/Input.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ module Phaser.Components.Sprite {
263263

264264
if (this.enabled)
265265
{
266+
this.enabled = false;
266267
this.game.input.removeGameObject(this.indexID);
267268
}
268269

@@ -578,7 +579,9 @@ module Phaser.Components.Sprite {
578579
if (this.dragFromCenter)
579580
{
580581
// Move the sprite to the middle of the pointer
581-
this._dragPoint.setTo(-this.sprite.worldView.halfWidth, -this.sprite.worldView.halfHeight);
582+
//this._dragPoint.setTo(-this.sprite.worldView.halfWidth, -this.sprite.worldView.halfHeight);
583+
//this._dragPoint.setTo(this.sprite.transform.center.x, this.sprite.transform.center.y);
584+
this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y);
582585
}
583586
else
584587
{

Phaser/core/Group.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ module Phaser {
527527
*/
528528
public remove(object, splice: bool = false) {
529529

530+
console.log('removing from group');
531+
530532
this._i = this.members.indexOf(object);
531533

532534
if (this._i < 0 || (this._i >= this.members.length))
@@ -544,6 +546,8 @@ module Phaser {
544546
this.members[this._i] = null;
545547
}
546548

549+
console.log('nulled');
550+
547551
if (object['events'])
548552
{
549553
object['events'].onRemovedFromGroup.dispatch(object, this);
@@ -615,7 +619,7 @@ module Phaser {
615619
public bringToTop(child): bool {
616620

617621
// If child not in this group, or is already at the top of the group, return false
618-
if (child.group.ID != this.ID || child.z == this._zCounter)
622+
if (!child || child.group == null || child.group.ID != this.ID || child.z == this._zCounter)
619623
{
620624
return false;
621625
}

Phaser/gameobjects/Tilemap.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ module Phaser {
229229
{
230230
var layer: TilemapLayer = new TilemapLayer(this.game, this, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight);
231231

232+
// Check it's a data layer
233+
if (!json.layers[i].data)
234+
{
235+
continue;
236+
}
237+
232238
layer.alpha = json.layers[i].opacity;
233239
layer.visible = json.layers[i].visible;
234240
layer.tileMargin = json.tilesets[0].margin;

Phaser/input/Input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ module Phaser {
507507

508508
if (this.inputObjects[index])
509509
{
510+
console.log('object removed from the input manager', index);
510511
this.inputObjects[index] = null;
511512
}
512513

Phaser/physics/advanced/Body.ts

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ module Phaser.Physics.Advanced {
143143
// Shapes
144144
public shapes: IShape[] = [];
145145

146+
// Length of the shapes array
147+
public shapesLength: number;
148+
146149
// Joints
147150
public joints: IJoint[] = [];
148151
public jointHash = {};
@@ -163,7 +166,7 @@ module Phaser.Physics.Advanced {
163166

164167
public duplicate() {
165168

166-
//console.log('body duplicate called');
169+
console.log('body duplicate called');
167170

168171
//var body = new Body(this.type, this.transform.t, this.angle);
169172

@@ -274,6 +277,8 @@ module Phaser.Physics.Advanced {
274277

275278
this.shapes.push(shape);
276279

280+
this.shapesLength = this.shapes.length;
281+
277282
return shape;
278283

279284
}
@@ -288,8 +293,9 @@ module Phaser.Physics.Advanced {
288293
shape.body = undefined;
289294
}
290295

291-
}
296+
this.shapesLength = this.shapes.length;
292297

298+
}
293299

294300
private setMass(mass) {
295301

@@ -307,8 +313,8 @@ module Phaser.Physics.Advanced {
307313

308314
public setTransform(pos, angle) {
309315

310-
this.transform.setTo(pos, angle);
311316
// inject the transform into this.position
317+
this.transform.setTo(pos, angle);
312318
Manager.write('setTransform: ' + this.position.toString());
313319
Manager.write('centroid: ' + this.centroid.toString());
314320
Phaser.TransformUtils.transform(this.transform, this.centroid, this.position);
@@ -399,20 +405,14 @@ module Phaser.Physics.Advanced {
399405

400406
if (!this.fixedRotation)
401407
{
402-
//this.setInertia(totalInertia - totalMass * vec2.dot(this.centroid, this.centroid));
403408
this.setInertia(totalInertia - totalMass * Phaser.Vec2Utils.dot(this.centroid, this.centroid));
404409
}
405410

406-
//console.log("mass = " + this.m + " inertia = " + this.i);
407-
408411
// Move center of mass
409412
var oldPosition: Phaser.Vec2 = Phaser.Vec2Utils.clone(this.position);
410-
//this.position.copyFrom(this.transform.transform(this.centroid));
411413
Phaser.TransformUtils.transform(this.transform, this.centroid, this.position);
412414

413415
// Update center of mass velocity
414-
415-
//this.velocity.mad(vec2.perp(vec2.sub(this.position, old_p)), this.angularVelocity);
416416
oldPosition.subtract(this.position);
417417
this.velocity.multiplyAddByScalar(Phaser.Vec2Utils.perp(oldPosition, oldPosition), this.angularVelocity);
418418

@@ -462,7 +462,6 @@ module Phaser.Physics.Advanced {
462462

463463
public updateVelocity(gravity, dt, damping) {
464464

465-
// this.velocity = vec2.mad(this.velocity, vec2.mad(gravity, this.force, this.massInverted), dt);
466465
Phaser.Vec2Utils.multiplyAdd(gravity, this.force, this.massInverted, this._tempVec2);
467466
Phaser.Vec2Utils.multiplyAdd(this.velocity, this._tempVec2, dt, this.velocity);
468467

@@ -513,17 +512,10 @@ module Phaser.Physics.Advanced {
513512
return v < min ? min : (v > max ? max : v);
514513
}
515514

516-
public updatePosition(dt) {
517-
518-
//console.log('body update pos', this.position.y);
519-
//console.log('pre add temp', this._tempVec2.y);
515+
public updatePosition(dt:number) {
520516

521-
//this.position.addself(vec2.scale(this.velocity, dt));
522517
this.position.add(Phaser.Vec2Utils.scale(this.velocity, dt, this._tempVec2));
523518

524-
//console.log('post add temp', this._tempVec2.y);
525-
//console.log('post add', this.position.y);
526-
527519
this.angle += this.angularVelocity * dt;
528520

529521
}
@@ -547,10 +539,8 @@ module Phaser.Physics.Advanced {
547539

548540
this.force.add(force);
549541

550-
// this.f.addself(force);
551-
// this.torque += vec2.cross(vec2.sub(p, this.p), force);
552-
553542
Phaser.Vec2Utils.subtract(p, this.position, this._tempVec2);
543+
554544
this.torque += Phaser.Vec2Utils.cross(this._tempVec2, force);
555545

556546
}
@@ -601,8 +591,6 @@ module Phaser.Physics.Advanced {
601591

602592
this.velocity.multiplyAddByScalar(impulse, this.massInverted);
603593

604-
// this.angularVelocity += vec2.cross(vec2.sub(p, this.position), impulse) * this.inertiaInverted;
605-
606594
Phaser.Vec2Utils.subtract(p, this.position, this._tempVec2);
607595

608596
this.angularVelocity += Phaser.Vec2Utils.cross(this._tempVec2, impulse) * this.inertiaInverted;

Phaser/physics/advanced/Manager.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module Phaser.Physics.Advanced {
3636
}
3737

3838
public static write(s: string) {
39-
//Manager.debug.textContent += s + "\n";
39+
Manager.debug.textContent += s + "\n";
4040
}
4141

4242
public static writeAll() {
@@ -119,10 +119,10 @@ module Phaser.Physics.Advanced {
119119
public lastTime: number = Date.now();
120120
public frameRateHz: number = 60;
121121
public timeDelta: number = 0;
122-
public paused: bool = false;
123-
public step: bool = false; // step through the simulation (i.e. per click)
124-
//public paused: bool = true;
122+
//public paused: bool = false;
125123
//public step: bool = false; // step through the simulation (i.e. per click)
124+
public paused: bool = true;
125+
public step: bool = false; // step through the simulation (i.e. per click)
126126
public velocityIterations: number = 8;
127127
public positionIterations: number = 4;
128128
//public velocityIterations: number = 1;
@@ -170,12 +170,6 @@ module Phaser.Physics.Advanced {
170170
{
171171
this.timeDelta = 0;
172172
}
173-
174-
//if (sceneIndex < demoArr.length)
175-
//{
176-
// demo = demoArr[sceneIndex];
177-
// demo.runFrame();
178-
//}
179173
}
180174

181175
//frameCount++;

0 commit comments

Comments
 (0)