ibb671 Posted April 24, 2016 Share Posted April 24, 2016 Hello im new to phaser and programming in general. I never really understood programming until I started with phaser. I'm enjoying it so far. I wanted to ask if anyone can help me with my code. I am practicing by making a project similar to the monster wants candy tutorial. I having trouble with the scoring of my game. Here is the section of the code that i have put in the update loop. killSprite:function(){ this.mothersDayItems.forEach(function(element){ if(element.y>this.game.world.height-130 && element.frame!=6){ element.kill(); this.decreaseScore();//starting score is 5 and this function decreases by 1 this.particleBurst(element.x,element.y-20); }else if(element.frame==6 && element.y>this.game.world.height-120){ element.kill(); this.particleBurst(element.x,element.y-20); } },this) }, When i console.log() the score when 1 item reaches the bottom it decreases almost up to -60. Hope this screen shot will help. Thank you guys in advance. Link to comment Share on other sites More sharing options...
rgk Posted April 25, 2016 Share Posted April 25, 2016 I would use forEachAlive. I might be picking up some data after the sprite gets killed, like element.y. Link to comment Share on other sites More sharing options...
ibb671 Posted April 25, 2016 Author Share Posted April 25, 2016 Thank you so much that worked. Link to comment Share on other sites More sharing options...
Recommended Posts