Jump to content

Overlap bugging after restart the game.


rhennig
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

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