2013-07-12 02:28:46 +00:00
|
|
|
/// <reference path="../../Phaser/Game.ts" />
|
2013-08-06 02:14:48 +00:00
|
|
|
/// <reference path="../../Phaser/ui/Button.ts" />
|
2013-07-12 02:28:46 +00:00
|
|
|
(function () {
|
2013-08-08 03:35:13 +00:00
|
|
|
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
|
|
|
function preload() {
|
2013-07-12 02:28:46 +00:00
|
|
|
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png');
|
|
|
|
game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json');
|
|
|
|
}
|
|
|
|
image:
|
2013-08-13 03:22:24 +00:00
|
|
|
Phaser.Sprite
|
2013-07-12 02:28:46 +00:00
|
|
|
button:
|
2013-08-13 03:22:24 +00:00
|
|
|
Phaser.UI.Button
|
2013-07-12 02:28:46 +00:00
|
|
|
function create() {
|
|
|
|
// This is just an image that we'll toggle the display of when you click the button
|
|
|
|
this.image = game.add.sprite(game.stage.centerX, 0, 'beast');
|
|
|
|
this.image.transform.origin.setTo(0.5, 0);
|
|
|
|
// This button is created from a texture atlas.
|
|
|
|
// Instead of frame IDs (like with a sprite sheet) we can tell it to use frame names instead.
|
|
|
|
// In this case our atlast frame names were called 'over', 'out' and 'down', but they could be anything you want.
|
|
|
|
// The function "clickedIt" will be called when the button is clicked or touched
|
|
|
|
this.button = game.add.button(game.stage.centerX, 400, 'button', clickedIt, this, 'over', 'out', 'down');
|
|
|
|
// Makes the button origin set to the middle
|
|
|
|
this.button.transform.origin.setTo(0.5, 0.5);
|
|
|
|
}
|
|
|
|
function update() {
|
|
|
|
// Rotate the button each frame, the button states will still work and respond.
|
|
|
|
this.button.rotation += 1;
|
|
|
|
}
|
|
|
|
function clickedIt() {
|
2013-08-13 03:22:24 +00:00
|
|
|
if(this.image.visible == true) {
|
2013-07-12 02:28:46 +00:00
|
|
|
this.image.visible = false;
|
|
|
|
} else {
|
|
|
|
this.image.visible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})();
|