Skip to content

Commit

Permalink
Updated all the examples that were using the old physicsEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
alvinsight committed Mar 13, 2014
1 parent c8e6358 commit 8a4d5ab
Show file tree
Hide file tree
Showing 12 changed files with 314 additions and 120 deletions.
369 changes: 266 additions & 103 deletions build/phaser.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions examples/_site/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,22 @@
"file": "load+polygon+2.js",
"title": "load polygon 2"
},
{
"file": "lock+constraint.js",
"title": "lock constraint"
},
{
"file": "postbroadphase+callback.js",
"title": "postbroadphase callback"
},
{
"file": "prismatic+constraint.js",
"title": "prismatic constraint"
},
{
"file": "revolute+constraint.js",
"title": "revolute constraint"
},
{
"file": "springs.js",
"title": "springs"
Expand Down
2 changes: 1 addition & 1 deletion examples/animation/change texture on click.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ function changeMummy() {

function render() {

game.debug.spriteBounds(bot);
game.debug.body(bot);

}
4 changes: 2 additions & 2 deletions examples/basics/03 - move an image.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function create() {
// and assign it to a variable
var image = game.add.sprite(0, 0, 'einstein');

image.physicsEnabled = true;
game.physics.enable(image, Phaser.Physics.ARCADE);

image.body.moveRight(150);
image.body.velocity.x=150;

}
4 changes: 3 additions & 1 deletion examples/camera/basic follow.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ function create() {
game.add.sprite(game.world.randomX, game.world.randomY, 'ufo');
}

game.physics.startSystem(Phaser.Physics.P2JS);

fixed = game.add.sprite(300, 320, 'player');
fixed.fixedToCamera = true;
fixed.cameraOffset.x = 300;
fixed.cameraOffset.y = 300;

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

player.physicsEnabled = true;
game.physics.p2.enable(player);

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

Expand Down
5 changes: 3 additions & 2 deletions examples/debug/debug physics.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ function create() {
sprite = game.add.sprite(0, 0, 'sprite');
sprite.alpha = 0.5 ;
sprite.x = game.width / 2 ;
sprite.physicsEnabled = true;

// create sprite B
otherSprite = game.add.sprite(0, 0, 'otherSprite');
otherSprite.alpha = 0.5 ;
otherSprite.x = (game.width / 2) + 150 ;
otherSprite.y = (game.height / 2) + 150 ;
otherSprite.physicsEnabled = true;

otherSprite.body.immovable = true ;

game.physics.enable([sprite,otherSprite], Phaser.Physics.ARCADE);
}

function update()
Expand Down
2 changes: 1 addition & 1 deletion examples/geometry/circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function create() {

function render () {

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

Expand Down
5 changes: 3 additions & 2 deletions examples/input/keyboard justpressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ function create() {
game.stage.backgroundColor = '#2d2d2d';

bullets = game.add.group();
bullets.enableBody = true;
bullets.physicsBodyType = Phaser.Physics.ARCADE;
bullets.createMultiple(10, 'bullet');
bullets.setAll('physicsEnabled',true);
bullets.callAll('events.onOutOfBounds.add', 'events.onOutOfBounds', resetBullet, this);

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

sprite.physicsEnabled = true;
game.physics.enable(sprite, Phaser.Physics.ARCADE);

// Stop the following keys from propagating up to the browser
game.input.keyboard.addKeyCapture([ Phaser.Keyboard.LEFT, Phaser.Keyboard.RIGHT, Phaser.Keyboard.SPACEBAR ]);
Expand Down
2 changes: 2 additions & 0 deletions examples/sprites/collide world bounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var pineapples;
function create() {

pineapples = game.add.group();
pineapples.enableBody = true;
pineapples.physicsBodyType = Phaser.Physics.ARCADE;

for (var i = 0; i < 10; i++)
{
Expand Down
6 changes: 3 additions & 3 deletions examples/sprites/out of bounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ var aliens;
function create() {

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

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

aliens = game.add.group();
aliens.enableBody = true;
aliens.physicsBodyType = Phaser.Physics.ARCADE;

for (var y = 0; y < 4; y++)
{
Expand All @@ -30,7 +31,6 @@ function create() {
alien.name = 'alien' + x.toString() + y.toString();
alien.checkWorldBounds = true;
alien.events.onOutOfBounds.add(alienOut, this);
alien.physicsEnabled = true;
alien.body.velocity.y = 50 + Math.random() * 200;
}
}
Expand Down
21 changes: 17 additions & 4 deletions examples/tile sprites/colliding with tiling sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,35 @@ function preload() {

function create() {

game.physics.arcade.gravity.y = 20;

ball = game.add.sprite(400, 0, 'ball');
ball.physicsEnabled = true;




game.physics.enable(ball, Phaser.Physics.ARCADE);

tilesprite = game.add.tileSprite(300, 450, 200, 100, 'starfield');

tilesprite.physicsEnabled = true;
// tilesprite.body.immovable = true;

// tilesprite.body.setRectangle(200, 100, 0, 0);

game.physics.enable(tilesprite, Phaser.Physics.ARCADE);


ball.body.collideWorldBounds = true;

tilesprite.body.collideWorldBounds = true;


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

}

function update() {

game.physics.arcade.collide(ball,tilesprite);

if (cursors.left.isDown)
{
tilesprite.x -= 8;
Expand Down
2 changes: 1 addition & 1 deletion examples/time/basic repeat event.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function createBall() {

var ball = game.add.sprite(game.world.randomX, 0, 'ball');

ball.physicsEnabled = true;
game.physics.enable(ball, Phaser.Physics.ARCADE);

}

Expand Down

0 comments on commit 8a4d5ab

Please sign in to comment.