mirror of
https://github.com/photonstorm/phaser
synced 2024-11-15 17:28:18 +00:00
Tilesprite test.
This commit is contained in:
parent
90e9edbf05
commit
5bbb7e390b
1 changed files with 43 additions and 0 deletions
43
examples/wip/tilesprite.js
Normal file
43
examples/wip/tilesprite.js
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
|
||||||
|
|
||||||
|
var tilesprite;
|
||||||
|
var cursors;
|
||||||
|
|
||||||
|
function preload() {
|
||||||
|
|
||||||
|
game.load.image('starfield', 'assets/misc/starfield.jpg');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function create() {
|
||||||
|
|
||||||
|
// tilesprite = game.add.tileSprite(0, 0, 800, 600, 'starfield');
|
||||||
|
|
||||||
|
tilesprite = game.add.tileSprite(100, 100, 400, 300, 'starfield');
|
||||||
|
|
||||||
|
cursors = game.input.keyboard.createCursorKeys();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
|
||||||
|
if (cursors.left.isDown)
|
||||||
|
{
|
||||||
|
tilesprite.tilePosition.x += 8;
|
||||||
|
}
|
||||||
|
else if (cursors.right.isDown)
|
||||||
|
{
|
||||||
|
tilesprite.tilePosition.x -= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cursors.up.isDown)
|
||||||
|
{
|
||||||
|
tilesprite.tilePosition.y += 8;
|
||||||
|
}
|
||||||
|
else if (cursors.down.isDown)
|
||||||
|
{
|
||||||
|
tilesprite.tilePosition.y -= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue