mirror of
https://github.com/photonstorm/phaser
synced 2024-09-21 15:01:57 +00:00
And some more examples updated :)
This commit is contained in:
parent
2669f81391
commit
b03c6231e1
8 changed files with 18 additions and 14 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue