TileSprites are now much more tidy and can run from a frame in a texture. They can also be animated. New TileSprite.autoScroll function added.

This commit is contained in:
photonstorm
2014-02-13 23:13:10 +00:00
parent 5bbb7e390b
commit 35e4c03bad
34 changed files with 1116 additions and 42 deletions
+60
View File
@@ -0,0 +1,60 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
game.load.image('ship', 'assets/sprites/thrust_ship2.png');
}
var ship;
var cursors;
function create() {
game.world.setBounds(0, 0, 1920, 1200);
var bg = game.add.sprite(0, 0, 'backdrop');
bg.alpha = 0.8;
ship = game.add.sprite(200, 200, 'ship');
ship.physicsEnabled = true;
game.camera.follow(ship);
cursors = game.input.keyboard.createCursorKeys();
game.physics.defaultRestitution = 0.8;
}
function update() {
if (cursors.left.isDown)
{
ship.body.rotateLeft(100);
}
else if (cursors.right.isDown)
{
ship.body.rotateRight(100);
}
else
{
ship.body.setZeroRotation();
}
if (cursors.up.isDown)
{
ship.body.thrust(400);
}
}
function render() {
// game.debug.renderText('x: ' + box2.body.velocity.x, 32, 32);
// game.debug.renderText('y: ' + box2.body.velocity.y, 32, 64);
}