soso

reviving killed ledges with new X and Y coordinates

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 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.