mirror of
https://github.com/wassname/phaser.git
synced 2026-07-31 12:40:07 +08:00
Test
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
}
|
||||
function render() {
|
||||
|
||||
game.debug.renderText('ufo added to game.world.group and "friendAndFoe" group', 20, 24);
|
||||
game.debug.renderText('ufo added to game.world.and "friendAndFoe" group', 20, 24);
|
||||
game.debug.renderText('others ONLY added to "enemies" group', 20, 40);
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
item.kill();
|
||||
}
|
||||
function reviveAll() {
|
||||
game.world.group.callAll('revive');
|
||||
game.world.callAll('revive');
|
||||
}
|
||||
function render() {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
}
|
||||
|
||||
var items;
|
||||
var items,
|
||||
card;
|
||||
|
||||
function create() {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
}
|
||||
function update() {
|
||||
// Animating alpha property of each item using forEach() method.
|
||||
game.world.group.forEach(function(item) {
|
||||
game.world.forEach(function(item) {
|
||||
// Update alpha first.
|
||||
item.alpha -= item.alphaIncSpeed;
|
||||
// Check for switch between increasing and descreasing.
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
timer = game.time.now +cycle;
|
||||
|
||||
// Get the first alive item and kill it.
|
||||
var item = game.world.group.getFirstAlive();
|
||||
var item = game.world.getFirstAlive();
|
||||
|
||||
if(item){
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
|
||||
game.debug.renderText('One item will be killed each second.', 280, 420);
|
||||
// Get living and dead number of a group.
|
||||
game.debug.renderText('Living: ' + game.world.group.countLiving() + ', Dead: ' + game.world.group.countDead(), 330, 440);
|
||||
game.debug.renderText('Living: ' + game.world.countLiving() + ', Dead: ' + game.world.countDead(), 330, 440);
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create,render:render});
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(1280, 800);
|
||||
game.world.setBounds(1280, 800);
|
||||
|
||||
game.load.image('ground', 'assets/tests/ground-2x.png');
|
||||
game.load.image('river', 'assets/tests/river-2x.png');
|
||||
@@ -44,28 +44,22 @@
|
||||
|
||||
// Add sky background to skyLayer.
|
||||
var sky = new Phaser.Sprite(game, 0, 0, 'sky');
|
||||
sky.scrollFactor.setTo(0, 0);
|
||||
skyLayer.add(sky);
|
||||
|
||||
// Add clouds to cloudLayer.
|
||||
var cloud0 = new Phaser.Sprite(game, 200, 120, 'cloud0');
|
||||
cloud0.scrollFactor.setTo(0.3, 0.1);
|
||||
var cloud1 = new Phaser.Sprite(game, -60, 120, 'cloud1');
|
||||
cloud1.scrollFactor.setTo(0.5, 0.1);
|
||||
var cloud2 = new Phaser.Sprite(game, 900, 170, 'cloud2');
|
||||
cloud2.scrollFactor.setTo(0.7, 0.1);
|
||||
cloudLayer.add(cloud0);
|
||||
cloudLayer.add(cloud1);
|
||||
cloudLayer.add(cloud2);
|
||||
|
||||
// Add ground sprite to groundLayer.
|
||||
var ground = new Phaser.Sprite(game, 0, 360, 'ground');
|
||||
ground.scrollFactor.setTo(0.5, 0.1);
|
||||
groundLayer.add(ground);
|
||||
|
||||
// Add river to riverLayer.
|
||||
var river = new Phaser.Sprite(game, 0, 400, 'river');
|
||||
river.scrollFactor.setTo(1.3, 0.16);
|
||||
riverLayer.add(river);
|
||||
|
||||
// Add sprites to spriteLayer.
|
||||
|
||||
@@ -28,18 +28,9 @@
|
||||
game.load.image('arm-r', 'assets/sprites/robot/arm-r.png');
|
||||
game.load.image('leg-l', 'assets/sprites/robot/leg-l.png');
|
||||
game.load.image('leg-r', 'assets/sprites/robot/leg-r.png');
|
||||
game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
|
||||
|
||||
}
|
||||
function create() {
|
||||
// Add some items.
|
||||
var item;
|
||||
for (var i = 0; i < 3; i++) {
|
||||
// Give the items a different alpha increase speed.
|
||||
item = game.add.sprite(290, 98 * (i + 1), 'item', i);
|
||||
// An item besides the left one.
|
||||
item = game.add.sprite(388, 98 * (i + 1), 'item', i + 3);
|
||||
}
|
||||
// Use groups of sprites to create a big robot.
|
||||
// Robot itself, you can subclass group class in a real game.
|
||||
robot = game.add.group();
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
game.debug.renderText('Recycle baddies from a group using getFirstExists.', 16, 24);
|
||||
game.debug.renderText('Notice that you cannot add more than 8 baddies since we only create 8 instance.', 16, 36);
|
||||
game.debug.renderText('Living baddies: ' + (enemies.countLiving()+1), 340, 420);
|
||||
game.debug.renderText('Living baddies: ' + (enemies.countLiving()), 340, 420);
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
}
|
||||
function resetAlpha() {
|
||||
// Set "alpha" value of all the childs.
|
||||
game.world.group.setAll('alpha', Math.random());
|
||||
game.world.setAll('alpha', Math.random());
|
||||
}
|
||||
function render() {
|
||||
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
game.load.image('atari2', 'assets/sprites/atari800xl.png');
|
||||
}
|
||||
|
||||
var atari1;
|
||||
var atari2;
|
||||
var atari1,
|
||||
atari2;
|
||||
|
||||
function create() {
|
||||
|
||||
// Items are rendered in the depth order in which they are added to the Group
|
||||
|
||||
atari1 = game.add.sprite(100, 100, 'atari1');
|
||||
atari2 = game.add.sprite(250, 90, 'atari2');
|
||||
|
||||
@@ -32,8 +31,8 @@
|
||||
|
||||
function swapSprites() {
|
||||
|
||||
// The 2 Sprites are in the global world Group, but this will work for any Group:
|
||||
game.world.group.swap(atari1, atari2);
|
||||
//The 2 Sprites are in the global world Group (World class extends the Group class), but this will work for any Group:
|
||||
game.world.swap(atari1, atari2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user