mirror of
https://github.com/wassname/phaser.git
synced 2026-08-12 12:20:38 +08:00
Added Group.sort, can sort the Group based on any given numeric property (x, y, health), finally you can do depth-sorting :)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create,update:update});
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
@@ -110,4 +110,13 @@ function update() {
|
||||
jumpTimer = game.time.now + 750;
|
||||
}
|
||||
|
||||
// player.scale.x += 0.001;
|
||||
// player.scale.y += 0.001;
|
||||
|
||||
}
|
||||
|
||||
function render () {
|
||||
|
||||
game.debug.renderSpriteBody(player);
|
||||
|
||||
}
|
||||
|
||||
@@ -23,10 +23,13 @@ function create() {
|
||||
sprite = group.create(300, 200, 'phaser');
|
||||
sprite.name = 'phaser-dude';
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
var names = [ 'cherries', 'orange', 'swede', 'apple', 'pepper', 'dick', 'carrot', 'cucum', 'strawb', 'broc', 'pineapl', 'melon', 'white', 'spud', 'banana', 'lettuce'];
|
||||
|
||||
for (var i = 0; i < names.length - 1; i++)
|
||||
{
|
||||
var c = group.create(game.world.randomX, game.world.randomY, 'veggies', game.rnd.integerInRange(0, 36));
|
||||
c.name = 'veg' + i;
|
||||
// var c = group.create(game.world.randomX, game.world.randomY, 'veggies', game.rnd.integerInRange(0, 36));
|
||||
var c = group.create(game.world.randomX, game.world.randomY, 'veggies', i);
|
||||
c.name = names[i];
|
||||
}
|
||||
|
||||
game.input.onUp.add(sortGroup, this);
|
||||
|
||||
Reference in New Issue
Block a user