mirror of
https://github.com/wassname/phaser.git
synced 2026-08-11 11:23:06 +08:00
Fixed lots of examples and added the missing Line.js.
This commit is contained in:
@@ -7,30 +7,20 @@ var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: p
|
||||
|
||||
}
|
||||
|
||||
var firstGroup;
|
||||
var yourGroup;
|
||||
|
||||
function create() {
|
||||
|
||||
// Here we'll create a new Group
|
||||
firstGroup = game.add.group();
|
||||
yourGroup = game.add.group();
|
||||
|
||||
// And add some sprites to it
|
||||
// And add 10 sprites to it
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
// Create a new sprite at a random screen location
|
||||
var newSprite = new Phaser.Sprite(game, game.stage.randomX, game.stage.randomY, 'sonic');
|
||||
|
||||
// This set-ups a listener for the event, view your console.log output to see the result
|
||||
newSprite.events.onAddedToGroup.add(logGroupAdd);
|
||||
|
||||
// Add the sprite to the Group
|
||||
firstGroup.add(newSprite);
|
||||
// Create a new sprite at a random world location
|
||||
yourGroup.create(game.world.randomX, game.world.randomY, 'sonic');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function logGroupAdd(sprite, group) {
|
||||
|
||||
console.log('Sprite added to Group', group.ID, 'at z-index:', group.getIndex(sprite));
|
||||
// Each sprite is now a member of yourGroup
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user