mirror of
https://github.com/wassname/phaser.git
synced 2026-09-10 12:29:30 +08:00
And some more examples updated :)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user