Skip to content

Commit 3ac8fba

Browse files
committed
Body.x/y didn't use pxpi. Also fixed out of bounds example.
1 parent 5c4dd26 commit 3ac8fba

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

examples/sprites/out of bounds.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ var aliens;
1313

1414
function create() {
1515

16+
// We only want world bounds on the left and right
17+
game.physics.setBoundsToWorld(true, true, false, false);
18+
game.physics.friction = 0;
19+
1620
player = game.add.sprite(400, 500, 'ship');
1721
player.anchor.setTo(0.5, 0.5);
1822

@@ -24,7 +28,9 @@ function create() {
2428
{
2529
var alien = aliens.create(200 + x * 48, y * 50, 'alien');
2630
alien.name = 'alien' + x.toString() + y.toString();
31+
alien.checkWorldBounds = true;
2732
alien.events.onOutOfBounds.add(alienOut, this);
33+
alien.physicsEnabled = true;
2834
alien.body.velocity.y = 50 + Math.random() * 200;
2935
}
3036
}

src/physics/Body.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,13 +1467,13 @@ Object.defineProperty(Phaser.Physics.Body.prototype, "x", {
14671467

14681468
get: function () {
14691469

1470-
return this.p2px(this.data.position[0]);
1470+
return this.p2pxi(this.data.position[0]);
14711471

14721472
},
14731473

14741474
set: function (value) {
14751475

1476-
this.data.position[0] = this.px2p(value);
1476+
this.data.position[0] = this.px2pi(value);
14771477

14781478
}
14791479

@@ -1487,13 +1487,13 @@ Object.defineProperty(Phaser.Physics.Body.prototype, "y", {
14871487

14881488
get: function () {
14891489

1490-
return this.p2px(this.data.position[1]);
1490+
return this.p2pxi(this.data.position[1]);
14911491

14921492
},
14931493

14941494
set: function (value) {
14951495

1496-
this.data.position[1] = this.px2p(value);
1496+
this.data.position[1] = this.px2pi(value);
14971497

14981498
}
14991499

0 commit comments

Comments
 (0)