Fixed lots of examples and added the missing Line.js.

This commit is contained in:
photonstorm
2014-01-31 14:12:20 +00:00
parent 26f2b2a931
commit 5e182d317b
14 changed files with 147 additions and 100 deletions
+6 -16
View File
@@ -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
}