Merge pull request #468 from alvinsight/1.2

Examples updated :)
This commit is contained in:
Richard Davey
2014-02-21 18:59:34 +00:00
14 changed files with 34 additions and 21 deletions
+3 -1
View File
@@ -19,6 +19,8 @@ function create() {
// and assign it to a variable
var image = game.add.sprite(0, 0, 'einstein');
image.body.velocity.x=50;
image.physicsEnabled = true;
image.body.moveRight(150);
}
+6 -4
View File
@@ -31,6 +31,8 @@ function create() {
player = game.add.sprite(150, 320, 'player');
player.physicsEnabled = true;
cursors = game.input.keyboard.createCursorKeys();
game.camera.follow(player);
@@ -39,15 +41,15 @@ function create() {
function update() {
player.body.velocity.setTo(0, 0);
player.body.setZeroVelocity();
if (cursors.up.isDown)
{
player.body.velocity.y = -200;
player.body.moveUp(200)
}
else if (cursors.down.isDown)
{
player.body.velocity.y = 200;
player.body.moveDown(200);
}
if (cursors.left.isDown)
@@ -56,7 +58,7 @@ function update() {
}
else if (cursors.right.isDown)
{
player.body.velocity.x = 200;
player.body.moveRight(200);
}
}
+1 -1
View File
@@ -42,7 +42,7 @@ function update() {
function render() {
game.debug.renderSpriteCorners(s, true, true);
game.debug.renderSpriteBounds(s);
game.debug.renderSpriteInfo(s, 20, 32);
}
+1 -1
View File
@@ -26,7 +26,7 @@ function create() {
function gofull() {
game.stage.scale.startFullScreen();
game.scale.startFullScreen();
}
+2 -2
View File
@@ -34,7 +34,7 @@ function create() {
var tempSprite = game.add.sprite(game.world.randomX, game.world.randomY, 'atari1');
tempSprite.name = 'atari' + i;
tempSprite.input.start(i, true);
tempSprite.inputEnabled = true;
tempSprite.input.enableDrag(false, true);
group1.add(tempSprite);
@@ -44,7 +44,7 @@ function create() {
var tempSprite=game.add.sprite(game.world.randomX, game.world.randomY, 'sonic');
tempSprite.name = 'sonic' + i;
tempSprite.input.start(10 + i, true);
tempSprite.inputEnabled = true;
tempSprite.input.enableDrag(false, true);
group2.add(tempSprite);
+2 -2
View File
@@ -19,12 +19,12 @@ function create() {
item = game.add.sprite(290, 98 * (i + 1), 'item', i);
// Enable input.
item.input.start(0, true);
item.inputEnabled = true;
item.events.onInputUp.add(kill);
// An item besides the left one.
item = game.add.sprite(388, 98 * (i + 1), 'item', i + 3);
item.input.start(0, true);
item.inputEnabled = true;
item.events.onInputUp.add(kill);
}
+2
View File
@@ -35,6 +35,8 @@ function create() {
// The player
sprite = group.create(300, 200, 'phaser');
sprite.physicsEnabled = true;
// Some trees
for (var i = 0; i < 50; i++)
{
+1 -1
View File
@@ -23,7 +23,7 @@ function create() {
// Directly create sprites from the group.
item = items.create(90, 90 * i, 'item', i);
// Enable input detection, then it's possible be dragged.
item.input.start(0,true);
item.inputEnabled = true;
// Make this item draggable.
item.input.enableDrag();
// Then we make it snap to 90x90 grids.
+2 -2
View File
@@ -25,12 +25,12 @@ function create() {
// Directly create sprites from the left group.
item = left.create(290, 98 * (i + 1), 'item', i);
// Enable input.
item.input.start(0, false, true);
item.inputEnabled = true;
item.events.onInputUp.add(select);
// Add another to the right group.
item = right.create(388, 98 * (i + 1), 'item', i + 3);
// Enable input.
item.input.start(0,true);
item.inputEnabled = true;
item.events.onInputUp.add(select);
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ function create() {
item = game.add.sprite(90, 90 * i, 'item', i);
// Enable input detection, then it's possible be dragged.
item.input.start(0,true);
item.inputEnabled = true;
// Make this item draggable.
item.input.enableDrag();
+8 -4
View File
@@ -14,6 +14,8 @@ function preload() {
}
var cursors;
function create() {
//We increase the size of our game world
@@ -25,26 +27,28 @@ function create() {
game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
}
cursors = game.input.keyboard.createCursorKeys();
}
function update() {
//This allows us to move the game camera using the keyboard
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
if (cursors.left.isDown)
{
game.camera.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
else if (cursors.right.isDown)
{
game.camera.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
if (cursors.up.isDown)
{
game.camera.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
else if (cursors.down.isDown)
{
game.camera.y += 4;
}
+3
View File
@@ -19,10 +19,13 @@ function create() {
bullets = game.add.group();
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;
// Stop the following keys from propagating up to the browser
game.input.keyboard.addKeyCapture([ Phaser.Keyboard.LEFT, Phaser.Keyboard.RIGHT, Phaser.Keyboard.SPACEBAR ]);
+1 -1
View File
@@ -18,7 +18,7 @@ function create() {
// Enable Input detection. Sprites have this disabled by default,
// so you have to start it if you want to interact with them.
sprite.input.start(0,true);
sprite.inputEnabled = true;
// This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
// or if it will snap to the center (true)
+1 -1
View File
@@ -18,7 +18,7 @@ function create() {
// Enable Input detection. Sprites have this disabled by default,
// so you have to start it if you want to interact with them.
sprite.input.start(0,true);
sprite.inputEnabled = true;
// This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
// or if it will snap to the center (true)