Skip to content

Commit

Permalink
Merge pull request phaserjs#557 from alvinsight/1.2
Browse files Browse the repository at this point in the history
Examples ready to be released !
  • Loading branch information
photonstorm committed Mar 13, 2014
2 parents c8e6358 + 726c423 commit 31d2d39
Show file tree
Hide file tree
Showing 15 changed files with 348 additions and 900 deletions.
1,168 changes: 290 additions & 878 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);

}
6 changes: 3 additions & 3 deletions examples/arcade physics/sprite vs group.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ function create() {

game.stage.backgroundColor = '#2d2d2d';

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

// This example will check Sprite vs. Group collision

sprite = game.add.sprite(32, 200, 'phaser');
sprite.name = 'phaser-dude';

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

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

for (var i = 0; i < 50; i++)
{
var c = group.create(game.rnd.integerInRange(100, 770), game.rnd.integerInRange(0, 570), 'veggies', game.rnd.integerInRange(0, 36));
var c = group.create(game.rnd.integerInRange(100, 770), game.rnd.integerInRange(0, 570), 'veggies', game.rnd.integerInRange(0, 35));
c.name = 'veg' + i;
c.body.immovable = true;
}
Expand Down
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
9 changes: 6 additions & 3 deletions examples/debug/debug physics.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ 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
3 changes: 2 additions & 1 deletion examples/input/follow mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var sprite;
function create() {

sprite = game.add.sprite(game.world.centerX, game.world.centerY, 'ball');
game.physics.enable(sprite, Phaser.Physics.ARCADE);

}

Expand All @@ -21,7 +22,7 @@ function update() {
if (game.input.mousePointer.isDown)
{
// 400 is the speed it will move towards the mouse
game.physics.moveToPointer(sprite, 400);
game.physics.arcade.moveToPointer(sprite, 400);

// if it's overlapping the mouse, don't move any more
if (Phaser.Rectangle.contains(sprite.body, game.input.x, game.input.y))
Expand Down
2 changes: 2 additions & 0 deletions examples/input/keyboard hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function create() {

game.stage.backgroundColor = '#736357';

game.add.text(0,0,'Press one, two or three !',{});

// Here we create 3 hotkeys, keys 1-3 and bind them all to their own functions

key1 = game.input.keyboard.addKey(Phaser.Keyboard.ONE);
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 31d2d39

Please sign in to comment.