mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 13:13:43 +00:00
52 lines
1.1 KiB
TypeScript
52 lines
1.1 KiB
TypeScript
/// <reference path="../../Phaser/Game.ts" />
|
|
|
|
(function () {
|
|
|
|
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
|
|
|
function init() {
|
|
|
|
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
|
game.load.image('atari2', 'assets/sprites/atari800xl.png');
|
|
game.load.image('card', 'assets/sprites/mana_card.png');
|
|
|
|
game.load.start();
|
|
|
|
}
|
|
|
|
var items: Phaser.Group;
|
|
var card: Phaser.Sprite;
|
|
|
|
function create() {
|
|
|
|
items = game.add.group();
|
|
|
|
// Items are rendered in the depth order in which they are added to the Group
|
|
|
|
items.addNewSprite(64, 100, 'atari1');
|
|
card = items.addNewSprite(240, 80, 'card');
|
|
items.addNewSprite(280, 100, 'atari2');
|
|
|
|
game.input.onTap.addOnce(removeCard, this);
|
|
|
|
}
|
|
|
|
function removeCard() {
|
|
|
|
// Now let's kill the card sprite
|
|
card.kill();
|
|
|
|
game.input.onTap.addOnce(replaceCard, this);
|
|
|
|
}
|
|
|
|
function replaceCard() {
|
|
|
|
// And bring it back to life again - I assume it will render in the same place as before?
|
|
var bob = items.getFirstDead();
|
|
|
|
bob.revive();
|
|
|
|
}
|
|
|
|
})();
|