mirror of
https://github.com/photonstorm/phaser
synced 2024-11-30 16:39:34 +00:00
29 lines
739 B
JavaScript
29 lines
739 B
JavaScript
|
|
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create });
|
|
|
|
function preload() {
|
|
|
|
game.load.spritesheet('coin', 'assets/sprites/coin.png', 32, 32);
|
|
|
|
}
|
|
|
|
var coins;
|
|
|
|
function create() {
|
|
|
|
// Here we create our coins group
|
|
coins = game.add.group();
|
|
|
|
// Now let's add 50 coins into it
|
|
for (var i = 0; i < 50; i++)
|
|
{
|
|
coins.create(game.world.randomX, game.world.randomY, 'coin', 0);
|
|
}
|
|
|
|
// Now using the power of callAll we can add the same animation to all coins in the group:
|
|
coins.callAll('animations.add', 'animations', 'spin', [0, 1, 2, 3, 4, 5], 10, true);
|
|
|
|
// And play them
|
|
coins.callAll('animations.play', 'animations', 'spin');
|
|
|
|
}
|