Skip to content

Instantly share code, notes, and snippets.

@OmarShehata
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OmarShehata/2b6ba3b1a391f3b876f2 to your computer and use it in GitHub Desktop.
Save OmarShehata/2b6ba3b1a391f3b876f2 to your computer and use it in GitHub Desktop.
<html>
<head>
<meta charset="UTF-8" />
<title>hello phaser!</title>
<script src="phaser.min.js"></script>
</head>
<body>
<script type="text/javascript">
window.onload = function() {
//This initializes Phaser
var WINDOW_WIDTH =800;
var WINDOW_HEIGHT = 600;
var game = new Phaser.Game(WINDOW_WIDTH, WINDOW_HEIGHT, Phaser.AUTO, '', { preload: preload, create: create,update:GameLoop });
var counter = 0;
var logo;
function preload () {
//Here is where you would load all your images and assets
game.load.image('logo', 'logo.png');//We bind the M3mal logo to the name "logo"
}
function create () {
//This function runs on creation of the game window
logo = game.add.sprite(game.world.centerX, game.world.centerY, 'logo');//We add "logo"
logo.anchor.setTo(0.5, 0.5);//This means the center of the sprite is its center, rather than its top left
}
function GameLoop(){
counter += 0.05;
logo.y = WINDOW_HEIGHT/2 + Math.sin(counter) * 100;
}
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment