mirror of
https://github.com/wassname/phaser.git
synced 2026-07-25 13:20:14 +08:00
* Fixed issue causing Keyboard.justPressed to always fire (thanks stemkoski)
* Added Keyboard.addKey() which creates a new Phaser.Key object that can be polled for updates, pressed states, etc. See the 2 new examples showing use.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
$title = "Keyboard justPressed";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
var phaser;
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('phaser', 'assets/sprites/phaser-dude.png');
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#736357';
|
||||
|
||||
phaser = game.add.sprite(300, 300, 'phaser');
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (game.input.keyboard.justPressed(Phaser.Keyboard.UP))
|
||||
{
|
||||
phaser.y--;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.justPressed(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
phaser.y++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
||||
Reference in New Issue
Block a user