mirror of
https://github.com/wassname/phaser.git
synced 2026-08-05 13:21:00 +08:00
Updated physics body to use localTransform. Updated tanks demo.
This commit is contained in:
@@ -5,8 +5,6 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create,update : update });
|
||||
|
||||
function preload() {
|
||||
@@ -14,41 +12,34 @@
|
||||
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
|
||||
game.load.image('background','assets/misc/starfield.jpg');
|
||||
|
||||
|
||||
}
|
||||
var button,
|
||||
background;
|
||||
|
||||
var button;
|
||||
var background;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#cccccc';
|
||||
|
||||
// the numbers given in parameters are the indexes of the frames, in this order :
|
||||
// over,out,down
|
||||
button = game.add.button(game.world.centerX, game.world.centerY, 'button', actionOnClick, this, 1, 0, 2);
|
||||
// The numbers given in parameters are the indexes of the frames, in this order: over, out, down
|
||||
button = game.add.button(game.world.centerX, game.world.centerY, 'button', actionOnClick, this, 2, 1, 0);
|
||||
|
||||
//set the anchor of the sprite in the center, otherwise it would rotate around the top-left corner
|
||||
// Set the anchor of the sprite in the center, otherwise it would rotate around the top-left corner
|
||||
button.anchor.setTo(0.5,0.5);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function actionOnClick () {
|
||||
|
||||
alert("Though I'm turning around, you can still click on me");
|
||||
|
||||
|
||||
}
|
||||
|
||||
function update () {
|
||||
|
||||
button.angle+=1;
|
||||
button.angle += 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user