rhennig Posted October 16, 2016 Share Posted October 16, 2016 Hello guys, I'm making a simple Phaser game and everything works fine on the first run, but after the game is finished and the player restart the game, a weird bug that seems to be caused by the star occur... I've tryed to understand what is happening here the whole day with no succes... =/ I've made a simple video to explain better... And here is the code from what seems to cause the problem. //creating falling star createStar : function() { this.random=[this.sc*2,this.sc*3,this.sc*7,this.sc*8]; this.rndd=this.game.rnd.pick(this.random); if(this.star==undefined) { this.star = this.game.add.sprite(this.rndd,this.game.world.top,'star'); }else if(!this.star.alive) { this.star.x=this.rndd; this.star.y=this.game.world.top; this.star.revive(); } }, //overlap test testOverlap : function(spriteA, spriteB) { var boundsA = spriteA.getBounds(); var boundsB = spriteB.getBounds(); return Phaser.Rectangle.intersects(boundsA, boundsB); }, update : function() { if ((this.testOverlap(this.baskball, this.star)&&(this.star.alive))) { this.star.kill(); this.starcount++; } } I hope someone can help me or has a tip. Sorry for my bad english and thanks in advice! Link to comment Share on other sites More sharing options...
rhennig Posted October 16, 2016 Author Share Posted October 16, 2016 Hello guys, I fixed the problem setting this.star to undefined on the shutdown function. I'm not sure why this dont happens automaticaly after the state is finished but... that is it. Problem solved! Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts