Jump to content

reviving killed ledges with new X and Y coordinates


soso
 Share

Recommended Posts

Hi, so I'm trying make a doodle jump type of a game , so far I've created the infinity world and added 6 ledges. now I want to kill and revive the ledges with the new X and Y coordinates, but somehow can't get it to work. I've managed to kill the ledges as they go out of camera bounds by using (forEachAlive)but got issues with reviving them. I've tried getFisrtDead and reset but nope, cant get it to work. Does anyone know how I could solve this? 

 

so this is how I create the platforms: 

generatePlatforms: function(){
//grouping the platforms
platformPool = game.add.group();
 
platformPool.enableBody = true;
 
var ground = game.add.sprite(0, game.world.height -32 ,'ground' );
platformPool.add(ground);
ground.scale.setTo(3,2);
ground.body.immovable = true;
 
 
for (var i= 0; i < 6; i++){
var randomX =game.rnd.integerInRange(0, game.world.width -50);
var randomY = game.world.height -100 *i;
ledge = game.add.sprite(randomX,randomY,'ground');
platformPool.add(ledge);
ledge.scale.setTo(0.3,0.3);
ledge.body.immovable =true;
}
 
},

 and this is how I kill the ledges under the update function: 

platformPool.forEachAlive(function(el){
var platformYMin = el.y;
if(el.inCamera == false){
el.kill();
} },this);
 

Thanks in advance 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...