2013-09-13 16:48:47 +00:00
|
|
|
<?php
|
|
|
|
$title = "Custom Sprite";
|
|
|
|
require('../head.php');
|
|
|
|
?>
|
2013-09-10 23:35:21 +00:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
// Here is a custom game object
|
2013-10-04 13:41:15 +00:00
|
|
|
MonsterBunny = function (game, x, y, rotateSpeed) {
|
2013-09-10 23:35:21 +00:00
|
|
|
|
|
|
|
Phaser.Sprite.call(this, game, x, y, 'bunny');
|
|
|
|
|
2013-10-04 13:41:15 +00:00
|
|
|
this.rotateSpeed = rotateSpeed;
|
|
|
|
|
2013-09-10 23:35:21 +00:00
|
|
|
};
|
|
|
|
|
2013-10-04 13:41:15 +00:00
|
|
|
MonsterBunny.prototype = Object.create(Phaser.Sprite.prototype);
|
2013-09-10 23:35:21 +00:00
|
|
|
MonsterBunny.prototype.constructor = MonsterBunny;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Automatically called by World.update
|
|
|
|
*/
|
|
|
|
MonsterBunny.prototype.update = function() {
|
|
|
|
|
2013-10-04 13:41:15 +00:00
|
|
|
this.angle += this.rotateSpeed;
|
2013-09-10 23:35:21 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-10-07 20:32:34 +00:00
|
|
|
|
2013-09-10 23:35:21 +00:00
|
|
|
|
2013-09-11 01:57:36 +00:00
|
|
|
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
|
2013-09-10 23:35:21 +00:00
|
|
|
|
|
|
|
function preload() {
|
|
|
|
|
|
|
|
game.load.image('bunny', 'assets/sprites/bunny.png');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
|
2013-10-04 13:41:15 +00:00
|
|
|
var wabbit = new MonsterBunny(game, 200, 300, 1);
|
2013-09-10 23:35:21 +00:00
|
|
|
wabbit.anchor.setTo(0.5, 0.5);
|
|
|
|
|
2013-10-04 13:41:15 +00:00
|
|
|
var wabbit2 = new MonsterBunny(game, 600, 300, 0.5);
|
|
|
|
wabbit2.anchor.setTo(0.5, 0.5);
|
|
|
|
|
2013-09-10 23:35:21 +00:00
|
|
|
game.add.existing(wabbit);
|
2013-10-04 13:41:15 +00:00
|
|
|
game.add.existing(wabbit2);
|
2013-09-10 23:35:21 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-10-07 20:32:34 +00:00
|
|
|
|
2013-09-10 23:35:21 +00:00
|
|
|
</script>
|
|
|
|
|
2013-09-13 16:48:47 +00:00
|
|
|
<?php
|
|
|
|
require('../foot.php');
|
|
|
|
?>
|