Jump to content

Search the Community

Showing results for tags 'phaser-pause'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. Hello, I'm finishing my game with Phaser and I got into implementing a pause and restarting the game when it's game over. I'd like to ask you more experienced phaser developers if the way I currently implementted is fine or if there are any drawbacks? I'm not sure if I'm not touching something I shouldn't have, so far the pause and restart do the thing perfectly but well inviting an unseen bug this way coul be also possible so I'd like to make sure. First of all I should have said that I wanted to implement pause, unpause and restart purely with phaser functionality without going to eventlistener outside the game (well it's the same thing but I expect that phaser has some shims and is ready for unexpected cases so I don't need to take care of them first). So I pause/unpause game with this.game.paused = true/false, when the game is over I do this.game.paused = true; after displaying a small window with score and text "Press space to continue". So I keep vision of the game stage in background when the game is over (I don't move to other state) and only if the space bar is pressed I restart main game state. Because I used game.paused which disables update function and all other things I went with this.game.input.keyboard.onDownCallback which has a check for game.paused && game.gameover to make sure that althought it is called on every key press it doesn't progress to do anything until the game is really over. So I'd like to ask if this part with keyboard.onDownCallback is fine, I set it manually but I'm not sure if it's not some generic thing which phaser uses for something else? Code: var style = {font: '28px Times New Roman', fill: '#ffffff'}; this.pauseText = this.game.add.text(this.game.width - 10, Math.floor(this.topBarHeight / 2), 'PAUSE', style); this.pauseText.inputEnabled = true; this.pauseText.events.onInputDown.add(this.pause, this); this.game.input.onDown.add(this.onKeyDown, this); this.game.input.keyboard.onDownCallback = this.onKeyDown.bind(this); pause: function() { if (!this.game.paused) { this.pauseScreen.renderable = true; this.game.paused = true; } }, unpause: function() { if (this.game.paused) { this.pauseScreen.renderable = false; this.game.paused = false; } }, onKeyDown: function() { if (this.game.paused && !this.gameover) { this.unpause(); } else if (this.game.paused && this.gameover) { if (this.spaceBar.isDown) { this.game.paused = false; this.state.start('game'); } } }, gameOver: function() { this.gameover = true; this.updateGameOverScreen(); this.gameOverBMD.addToWorld(Math.floor(this.game.width / 2 - this.goW / 2), Math.floor(this.game.height / 2 - this.goH / 2)); this.game.paused = true; return true; } Thank you, I think it's not a problem but I'd like to make sure with you.
×
×
  • Create New...