Jump to content

phaser gameover screen


Recommended Posts

Hi, i'm creating a gameover screen and i made it .. now i want color faded or like an overlay screen around gameover screen group. 

this is the code snippet i'm using ... 

        this.gameOverScreenGroup = this.game.add.group();
        this.gameOverScreenGroup.x = 197;
        this.gameOverScreenGroup.y = 52;
        var gameOverBGScreen = this.game.add.bitmapData(this.game.width,this.game.height);
        gameOverBGScreen.ctx.fillStyle = "#d5d2cc"
        /* Game Over screen BG */
        this.gameOverBG = this.game.add.graphics(0,0,this.gameOverScreenGroup);
       // this.gameOverBG.lineStyle(2, 0xFFFF00, 1.0);
        this.gameOverBG.beginFill(0xfaecbe, 1);
        this.gameOverBG.width = 630;
        this.gameOverBG.height = 600; 
       // this.gameOverScreenGroup.add(gameOverBGScreen)
        //this.gameOverScreenGroup.x = this.gameOverBG.x;
        //this.gameOverScreenGroup.y = this.gameOverBG.y;

        var star_1 = this.game.add.sprite(60, 74,'UI', 'star',this.gameOverScreenGroup);
        var star_2 = this.game.add.sprite(star_1.width+110, 44,'UI', 'star',this.gameOverScreenGroup);
        var star_3 = this.game.add.sprite(star_2.width*2+160, 74,'UI', 'star',this.gameOverScreenGroup);

         this.nextBtn = this.game.add.sprite(209, 226,'UI', 'btn_next',this.gameOverScreenGroup);
         this.nextBtn.inputEnabled = false;

Link to comment
Share on other sites

Are you just trying to get a semi transparent overlay drawn behind your menu? This is the code I use to do that:

var bmd = game.add.bitmapData(1, 1);
bmd.fill(0, 0, 0);
var semiTransparentOverlay = game.add.sprite(0, 0, bmd);
semiTransparentOverlay.scale.setTo(game.width, game.height);
semiTransparentOverlay.alpha = 0;
game.add.tween(semiTransparentOverlay).to({alpha:0.5}, 500, Phaser.Easing.Quadratic.In, true);


In the future, when you make a new post, there is a button in the tool bar on this forum that will let you format your code to make it easier to read. That's what I used above to make the text look like it does.

Link to comment
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.

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.


  • Recently Browsing   0 members

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