Skip to content

Commit d09da54

Browse files
committed
Updated the arcade physics examples according to the lastest changes
1 parent 8fff386 commit d09da54

34 files changed

Lines changed: 183 additions & 92 deletions

examples/arcade physics/accelerate to pointer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ function create() {
1414
sprite = game.add.sprite(400, 300, 'arrow');
1515
sprite.anchor.setTo(0.5, 0.5);
1616

17+
game.physics.enable(sprite, Phaser.Physics.ARCADE);
18+
1719
}
1820

1921
function update() {
2022

21-
sprite.rotation = game.physics.accelerateToPointer(sprite, this.game.input.activePointer, 500, 500, 500);
23+
game.physics.arcade.moveToPointer(sprite, game.input.activePointer, 60, 500, 500);
2224

2325
}
2426

examples/arcade physics/angle between.js

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

2828
function update() {
2929

30-
arrow.rotation = game.physics.angleBetween(arrow, target);
30+
arrow.rotation = game.physics.arcade.angleBetween(arrow, target);
3131

3232
}
3333

examples/arcade physics/angle to pointer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function update() {
2020

2121
// This will update the sprite.rotation so that it points to the currently active pointer
2222
// On a Desktop that is the mouse, on mobile the most recent finger press.
23-
sprite.rotation = game.physics.angleToPointer(sprite);
23+
sprite.rotation = game.physics.arcade.angleToPointer(sprite);
2424

2525
}
2626

examples/arcade physics/angular acceleration.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ function create() {
1414
sprite = game.add.sprite(400, 300, 'arrow');
1515
sprite.anchor.setTo(0.5, 0.5);
1616

17+
game.physics.enable(sprite, Phaser.Physics.ARCADE);
18+
1719
// We'll set a lower max angular velocity here to keep it from going totally nuts
1820
sprite.body.maxAngular = 500;
1921

examples/arcade physics/angular velocity.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function create() {
1313

1414
sprite = game.add.sprite(400, 300, 'arrow');
1515
sprite.anchor.setTo(0.5, 0.5);
16+
game.physics.enable(sprite, Phaser.Physics.ARCADE);
1617

1718
}
1819

@@ -33,7 +34,7 @@ function update() {
3334

3435
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
3536
{
36-
game.physics.velocityFromAngle(sprite.angle, 300, sprite.body.velocity);
37+
game.physics.arcade.velocityFromAngle(sprite.angle, 300, sprite.body.velocity);
3738
}
3839

3940
}

examples/arcade physics/body scale.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ function create() {
2020
sprite = game.add.sprite(200, 300, 'gameboy', 2);
2121
sprite.name = 'green';
2222
sprite.anchor.setTo(0.5, 0.5);
23+
24+
game.physics.enable(sprite, Phaser.Physics.ARCADE);
2325
sprite.body.immovable = true;
2426

2527
sprite2 = game.add.sprite(600, 270, 'gameboy', 3);
2628
sprite2.name = 'yellow';
29+
game.physics.enable(sprite2, Phaser.Physics.ARCADE);
2730
sprite2.body.rebound = false;
2831

2932
game.add.tween(sprite.scale).to( { x: 3, y: 3 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);
@@ -34,13 +37,13 @@ function update() {
3437

3538
sprite2.body.velocity.x = -200;
3639

37-
game.physics.collide(sprite, sprite2);
40+
game.physics.arcade.collide(sprite, sprite2);
3841

3942
}
4043

4144
function render() {
4245

43-
game.debug.physicsBody(sprite.body);
44-
game.debug.physicsBody(sprite2.body);
46+
// game.debug.physicsBody(sprite.body);
47+
// game.debug.physicsBody(sprite2.body);
4548

4649
}

examples/arcade physics/bounce accelerator.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ function create() {
1919

2020
flyer.animations.add('left', [0, 1, 2, 3], 10, true);
2121
flyer.animations.add('right', [5, 6, 7, 8], 10, true);
22+
23+
game.physics.enable(flyer, Phaser.Physics.ARCADE);
2224

2325
// This gets it moving
2426
flyer.body.velocity.setTo(200, 200);

examples/arcade physics/bounce knock.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ function create() {
2222
ball = game.add.sprite(400, 200, 'ball');
2323

2424
knocker = game.add.sprite(400, 200, 'dude');
25+
26+
game.physics.enable([knocker,ball], Phaser.Physics.ARCADE);
2527
knocker.body.immovable = true;
2628

2729
// This gets it moving
@@ -44,7 +46,7 @@ function create() {
4446
function update () {
4547

4648
// Enable physics between the knocker and the ball
47-
game.physics.collide(knocker, ball);
49+
game.physics.arcade.collide(knocker, ball);
4850

4951
if (cursors.up.isDown)
5052
{

examples/arcade physics/bounce with gravity.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ function create() {
2020

2121
// This creates a simple sprite that is using our loaded image and displays it on-screen and assign it to a variable
2222
image = game.add.sprite(400, 200, 'flyer');
23+
24+
game.physics.enable(image, Phaser.Physics.ARCADE);
2325

2426
// This gets it moving
2527
image.body.velocity.setTo(200, 200);

examples/arcade physics/bounce.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ function create() {
2222
// displays it on-screen
2323
// and assign it to a variable
2424
image = game.add.sprite(0, 0, 'flyer');
25+
26+
game.physics.enable(image, Phaser.Physics.ARCADE);
2527

2628
// This gets it moving
2729
image.body.velocity.setTo(200,200);

0 commit comments

Comments
 (0)