mirror of
https://github.com/wassname/phaser.git
synced 2026-07-11 00:40:20 +08:00
Physics integration and a fix to Tween that stopped the repeat/yoyo from working.
This commit is contained in:
+16
-31
@@ -16,56 +16,41 @@
|
||||
|
||||
function preload() {
|
||||
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
|
||||
game.load.image('bunny', 'assets/sprites/bunny.png');
|
||||
}
|
||||
|
||||
var s;
|
||||
var bunny;
|
||||
var bot;
|
||||
|
||||
function create() {
|
||||
|
||||
game.world._stage.backgroundColorString = '#182d3b';
|
||||
|
||||
s = game.add.sprite(game.world.centerX, game.world.centerY, 'bot');
|
||||
// s.anchor.setTo(0.5, 0.5);
|
||||
bunny = game.add.sprite(500, game.world.centerY, 'bunny');
|
||||
bunny.anchor.setTo(0.5, 0.5);
|
||||
|
||||
// s.body.offset.setTo(0, 0);
|
||||
bot = game.add.sprite(150, game.world.centerY, 'bot');
|
||||
bot.anchor.setTo(0.5, 0.5);
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
|
||||
|
||||
// s.scale.setTo(2, 2);
|
||||
|
||||
s.animations.add('run');
|
||||
s.animations.play('run', 10, true);
|
||||
game.add.tween(bot.scale).to({ x: 3, y: 3 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
s.rotation += 0.01;
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
s.x -= 4;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
s.x += 4;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
s.y -= 4;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
s.y += 4;
|
||||
}
|
||||
bunny.angle += 1;
|
||||
bot.angle += 1;
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderSpriteCorners(s, true, true);
|
||||
// game.debug.renderRectangle(s.body.bounds, 'rgba(255,0,0,0.3)');
|
||||
game.debug.renderSpriteInfo(s, 20, 32);
|
||||
game.debug.renderSpriteCorners(bunny, true, true);
|
||||
game.debug.renderSpriteCorners(bot, true, true);
|
||||
game.debug.renderSpriteInfo(bunny, 20, 32);
|
||||
game.debug.renderSpriteInfo(bot, 20, 132);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user