Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="UTF-8" />
- <title>Simple game</title>
- <script src="phaser.min.js"></script>
- </head>
- <body>
- <script type="text/javascript">
- var game = new Phaser.Game(640, 480, Phaser.AUTO, '', { preload: preload, create: create, update: update });
- var player;
- var cursors;
- function preload() {
- game.load.image('asset', 'assets/asset.png');
- cursors = game.input.keyboard.createCursorKeys();
- }
- function create() {
- player = game.add.sprite(100, 100, 'asset');
- }
- function update() {
- if(cursors.left.isDown){
- player.x -= 1;
- }
- if(cursors.right.isDown){
- player.x += 1;
- }
- if (cursors.down.isDown){
- player.y += 1;
- }
- if (cursors.up.isDown){
- player.y -= 1;
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement