Skip to content

Commit 8a4d5ab

Browse files
committed
Updated all the examples that were using the old physicsEnabled
1 parent c8e6358 commit 8a4d5ab

12 files changed

Lines changed: 314 additions & 120 deletions

File tree

build/phaser.js

Lines changed: 266 additions & 103 deletions
Large diffs are not rendered by default.

examples/_site/examples.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,22 @@
708708
"file": "load+polygon+2.js",
709709
"title": "load polygon 2"
710710
},
711+
{
712+
"file": "lock+constraint.js",
713+
"title": "lock constraint"
714+
},
711715
{
712716
"file": "postbroadphase+callback.js",
713717
"title": "postbroadphase callback"
714718
},
719+
{
720+
"file": "prismatic+constraint.js",
721+
"title": "prismatic constraint"
722+
},
723+
{
724+
"file": "revolute+constraint.js",
725+
"title": "revolute constraint"
726+
},
715727
{
716728
"file": "springs.js",
717729
"title": "springs"

examples/animation/change texture on click.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ function changeMummy() {
3434

3535
function render() {
3636

37-
game.debug.spriteBounds(bot);
37+
game.debug.body(bot);
3838

3939
}

examples/basics/03 - move an image.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function create() {
1919
// and assign it to a variable
2020
var image = game.add.sprite(0, 0, 'einstein');
2121

22-
image.physicsEnabled = true;
22+
game.physics.enable(image, Phaser.Physics.ARCADE);
2323

24-
image.body.moveRight(150);
24+
image.body.velocity.x=150;
2525

2626
}

examples/camera/basic follow.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ function create() {
2424
game.add.sprite(game.world.randomX, game.world.randomY, 'ufo');
2525
}
2626

27+
game.physics.startSystem(Phaser.Physics.P2JS);
28+
2729
fixed = game.add.sprite(300, 320, 'player');
2830
fixed.fixedToCamera = true;
2931
fixed.cameraOffset.x = 300;
3032
fixed.cameraOffset.y = 300;
3133

3234
player = game.add.sprite(150, 320, 'player');
3335

34-
player.physicsEnabled = true;
36+
game.physics.p2.enable(player);
3537

3638
cursors = game.input.keyboard.createCursorKeys();
3739

examples/debug/debug physics.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ function create() {
2020
sprite = game.add.sprite(0, 0, 'sprite');
2121
sprite.alpha = 0.5 ;
2222
sprite.x = game.width / 2 ;
23-
sprite.physicsEnabled = true;
2423

2524
// create sprite B
2625
otherSprite = game.add.sprite(0, 0, 'otherSprite');
2726
otherSprite.alpha = 0.5 ;
2827
otherSprite.x = (game.width / 2) + 150 ;
2928
otherSprite.y = (game.height / 2) + 150 ;
30-
otherSprite.physicsEnabled = true;
29+
3130
otherSprite.body.immovable = true ;
31+
32+
game.physics.enable([sprite,otherSprite], Phaser.Physics.ARCADE);
3233
}
3334

3435
function update()

examples/geometry/circle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function create() {
1212

1313
function render () {
1414

15-
game.debug.circle(circle,'#cfffff');
15+
game.debug.geom(circle,'#cfffff');
1616
game.debug.text('Diameter : '+circle.diameter,50,200);
1717
game.debug.text('Circumference : '+circle.circumference(),50,230);
1818

examples/input/keyboard justpressed.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ function create() {
1818
game.stage.backgroundColor = '#2d2d2d';
1919

2020
bullets = game.add.group();
21+
bullets.enableBody = true;
22+
bullets.physicsBodyType = Phaser.Physics.ARCADE;
2123
bullets.createMultiple(10, 'bullet');
22-
bullets.setAll('physicsEnabled',true);
2324
bullets.callAll('events.onOutOfBounds.add', 'events.onOutOfBounds', resetBullet, this);
2425

2526
sprite = game.add.sprite(400, 550, 'phaser');
2627

27-
sprite.physicsEnabled = true;
28+
game.physics.enable(sprite, Phaser.Physics.ARCADE);
2829

2930
// Stop the following keys from propagating up to the browser
3031
game.input.keyboard.addKeyCapture([ Phaser.Keyboard.LEFT, Phaser.Keyboard.RIGHT, Phaser.Keyboard.SPACEBAR ]);

examples/sprites/collide world bounds.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ var pineapples;
1111
function create() {
1212

1313
pineapples = game.add.group();
14+
pineapples.enableBody = true;
15+
pineapples.physicsBodyType = Phaser.Physics.ARCADE;
1416

1517
for (var i = 0; i < 10; i++)
1618
{

examples/sprites/out of bounds.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ var aliens;
1414
function create() {
1515

1616
// We only want world bounds on the left and right
17-
game.physics.setBoundsToWorld(true, true, false, false);
18-
game.physics.friction = 0;
17+
game.physics.setBoundsToWorld();
1918

2019
player = game.add.sprite(400, 500, 'ship');
2120
player.anchor.setTo(0.5, 0.5);
2221

2322
aliens = game.add.group();
23+
aliens.enableBody = true;
24+
aliens.physicsBodyType = Phaser.Physics.ARCADE;
2425

2526
for (var y = 0; y < 4; y++)
2627
{
@@ -30,7 +31,6 @@ function create() {
3031
alien.name = 'alien' + x.toString() + y.toString();
3132
alien.checkWorldBounds = true;
3233
alien.events.onOutOfBounds.add(alienOut, this);
33-
alien.physicsEnabled = true;
3434
alien.body.velocity.y = 50 + Math.random() * 200;
3535
}
3636
}

0 commit comments

Comments
 (0)