2013-08-29 21:53:55 +00:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>phaser.js - a new beginning</title>
|
|
|
|
<?php
|
|
|
|
require('js.php');
|
|
|
|
?>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
|
|
|
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }, false, true);
|
|
|
|
|
|
|
|
var bunny;
|
|
|
|
|
|
|
|
function preload() {
|
|
|
|
game.load.atlasJSONHash('monsters', 'assets/sprites/pixi_monsters.png', 'assets/sprites/pixi_monsters.json');
|
|
|
|
}
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
|
2013-08-30 01:18:00 +00:00
|
|
|
// This is created by the very act of loading a texture atlas in
|
2013-08-30 01:00:30 +00:00
|
|
|
frameData = game.cache.getFrameData('monsters');
|
2013-08-30 00:50:17 +00:00
|
|
|
|
2013-08-30 01:18:00 +00:00
|
|
|
// Both of these work - they look fugly I know, but they'll be hidden behind a Phaser Sprite anyway
|
2013-08-30 01:00:30 +00:00
|
|
|
bunny = PIXI.Sprite.fromFrame(frameData.getFrame(0).uuid);
|
|
|
|
// bunny = PIXI.Sprite.fromFrame(frameData.getFrameByName('skully.png').uuid);
|
2013-08-29 21:53:55 +00:00
|
|
|
|
|
|
|
bunny.anchor.x = 0.5;
|
|
|
|
bunny.anchor.y = 0.5;
|
|
|
|
|
|
|
|
bunny.position.x = game.world.centerX;
|
|
|
|
bunny.position.y = game.world.centerY;
|
|
|
|
|
|
|
|
game.world.add(bunny);
|
|
|
|
|
2013-08-30 01:00:30 +00:00
|
|
|
n = game.time.now + 1000;
|
|
|
|
|
2013-08-29 21:53:55 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 01:00:30 +00:00
|
|
|
var frameData;
|
|
|
|
var f = 0;
|
|
|
|
var n = 0;
|
|
|
|
|
2013-08-29 21:53:55 +00:00
|
|
|
function update() {
|
|
|
|
|
2013-08-30 01:00:30 +00:00
|
|
|
if (game.time.now > n)
|
2013-08-29 21:53:55 +00:00
|
|
|
{
|
2013-08-30 01:00:30 +00:00
|
|
|
f = game.math.wrapValue(f, 1, 4);
|
|
|
|
|
|
|
|
bunny.setTexture(PIXI.TextureCache[frameData.getFrame(f).uuid]);
|
|
|
|
|
2013-08-30 01:18:00 +00:00
|
|
|
n = game.time.now + 500;
|
2013-08-29 21:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|