0
私はclouds
グループを持っており、2つの雲を生成します。 10秒ごとに私はそれらの雲を殺し、さらに2つの雲を産みたい。一度にグループのすべての要素を殺すことはできますか?グループ内のすべての要素を殺す(Phaser)
var clouds;
var start = new Date();
var count = 0;
function preload(){
game.load.image('cloud', 'assets/cloud.png');
}
function create(){
clouds = game.add.group();
}
function update(){
if(count < 10){
createCloud();
}
}
function createCloud(){
var elapsed = new Date() - start;
if(elapsed > 10000){
var locationCount = 0;
//Here is where I'm pretty sure I need to
//kill all entities in the cloud group here before I make new clouds
while(locationCount < 2){
//for the example let's say I have a random number
//between 1 and 3 stored in randomNumber
placeCloud(randomNumber);
locationCount++;
count++;
}
}
}
function placeCloud(location){
if(location == 1){
var cloud = clouds.create(170.5, 200, 'cloud');
}else if(location == 2){
var cloud = clouds.create(511.5, 200, 'cloud');
}else{
var cloud = clouds.create(852.5, 200, 'cloud');
}
}