Jump to content

Text to disappear


Recommended Posts

Hi guys got a simple question i think but i am really new to phaser.

trying to get some text to disapear after a few seconds, i am using phaser and i am not to sure how to do this:

Simnpley i have :

Asteroid.time.events.remove(Phaser.Timer.SECOND - 3, this.startInstructions3, this);

My text appears on the page fine :

if (!this.rockmodel.countLiving()) {
    Asteroid.time.events.add(Phaser.Timer.SECOND * 3, this.levelIncrease, this);
    var startInstructions3 = 'NEXT LEVEL! ';
    this.gametext3 = Asteroid.add.text(Asteroid.world.centerX, Asteroid.world.centerY, startInstructions3, lifefont3.thefont3);
    this.gametext3.align = 'center';
    this.gametext3.anchor.set(0.5, 0.5);

Then when i go back to my levelincrease function i have : 

   if (this.rockcount < rocksincoming.max) {
            this.rockcount += rocksincoming.astup;

        Asteroid.time.events.remove(Phaser.Timer.SECOND * 3, this.startInstructions3, this);
        endofgame: function () {
Link to comment
Share on other sites

Hi, time.events.remove will try to remove the event, if you want to simply disappear text use:


and if you want some delay (eg. 3s) you can use:

Asteroid.time.events.add(3000, this.gametext3.kill, this);


If you don't need gametext3 any more consider using destroy() instead of kill() :)

Link to comment
Share on other sites


  • Recently Browsing   0 members

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