Created
June 9, 2017 00:12
-
-
Save zacharyhill/3c7f598fceaeee23240844d02f8436fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <title>hello phaser!</title> | |
| <script src="./node_modules/phaser-ce/build/phaser.min.js"></script> | |
| </head> | |
| <body> | |
| <script type="text/javascript"> | |
| window.onload = function() { | |
| var game = new Phaser.Game(800, 400, Phaser.CANVAS, '', { preload: preload, create: create, update: update }); | |
| function preload () { | |
| game.load.image('background', | |
| './assets/desert_BG.png' | |
| ); | |
| game.load.atlas('player-atlas', | |
| './assets/player.png', | |
| './assets/player.json' | |
| ); | |
| } | |
| function create () { | |
| game.things = game.add.physicsGroup( | |
| Phaser.Physics.ARCADE, | |
| game.world, | |
| 'things' | |
| ); | |
| const bg = game.add.sprite(0, 0, 'background'); | |
| const player = game.things.create( | |
| 0, 0, | |
| 'player-atlas', | |
| 'Idle(1).png' | |
| ); | |
| game.add.sprite(player); | |
| player.health = 5; | |
| player.animations.add( | |
| 'running', | |
| [ | |
| 'Run(1).png', | |
| 'Run(2).png', | |
| 'Run(3).png', | |
| 'Run(4).png', | |
| ], | |
| 5, true, false); | |
| player.animations.play('running'); | |
| player.body.velocity.setTo(20, 0); | |
| } | |
| function update() { | |
| } | |
| }; | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment