Jump to content

Search the Community

Showing results for tags 'restart'.

  • 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 13 results

  1. hi, I've been using phaser for some time now but am having some issue with my game when I press the restart button. My game goes into an infinite loop and my player can't jump as high as he used to before. Its like as if gravity increased on the stage. and other objects disappear too like they go all the way down to the screen Can somebody tell me whats wrong here retry: function () { //this.clearCurrentState() this.levelSong.pause() this.winSong.pause() this.gameOverSong.pause() this.shutdown() this.game.state.start('Level2') }, shutdown:function() { this.game.world.removeAll() }, here is the link to my game (My problem is in level 2): https://exit-exitar.firebaseapp.com
  2. Hello Everyone, I am trying to develop a breakout type game. But can't restart the game. Is there any easy way to do that? Thanks in advance.
  3. Hello everyone! I just recently got into PIXI.js and started with a tutorial from kittykatattack on GitHub which can be found here: https://github.com/kittykatattack/learningPixi#introduction I finished the tutorial and everything works great! After that I wanted to expand the game and add a "Try again" or "Play again" button to the end scene and I got that to work aswell. But each time the game restarts it gets quicker and quicker. It seems like the speed is doubling on each restart. I added this code to the end state function: tryAgainMessage.click; playAgainMessage.click; tryAgainMessage.click = function (e) { for (var i = stage.children.length - 1; i >= 0; i--) { stage.removeChild(stage.children[i]);}; gameScene.visible = true; gameOverScene.visible = false; state = setup; } playAgainMessage.click = function (e) { for (var i = stage.children.length - 1; i >= 0; i--) { stage.removeChild(stage.children[i]);}; gameScene.visible = true; gameOverScene.visible = false; state = setup; } Does anyone know how I can properly restart the game once the message is clicked?
  4. Hi everyone, there might be a way of doing this but I must be missing something... I have a scene which consists of different meshes having different animations, all of the animation only run once. Basically, I would like to be able to "reload" the scene without actually reloading it, which I try to reset all the meshes' animations by pausing all unfinished meshes' animatable, set their animation's frame back to zero, and restart each of the animatable again. This method work when all of the animatables in scene have not reached their last frame. It won't work on those animatable who had reached its last frame, which their frame will be set to zero, but not able to be restarted. A simplified scene that showing my approach, as you will see the restart button doesn't work when the animation has reached its last frame. http://www.babylonjs-playground.com/#OQENJ Any help would be appreciated, thank you!
  5. Hello! I am making a waste sorting game and when the player loses all their lives, I wish to restart the game. I click the 'RETRY' text and the state reloads, but it seems that my life and garbage sprites never reload. I am wondering if it is because they are in an array (see this.garbage = []; and this.lifeSprites = [];). I have never used game.state.start to reload a state multiple times, I have only ever used it to call a state once. If I cannot get game.state.start to reload my game, I will create a restart() method with some re-positioning code and whatnot. BUT it would be way awesome if I could figure out why this doesn't work!! Below is my code and here is a link to my game so far (my code is still mucho messy). Arrow keys to rotate on desktop. BasicGame.Game = function (game) { this.firstDrop = true; this.garbage = []; this.MAX_TRASH = 5; this.lowestTrash = null; this.lastLowestTrash = null; this.lowestTrashType = null; this.lives = 3; this.lifeSprites = []; this.gap = 500; this.MIN_GAP = 250; this.fallSpeed = 3; this.MAX_FALL_SPEED = 5.5; this.sorter = null; this.rotationSpeed = 10; this.targetRotation = null; this.isRotating = false; this.clockwise = true; this.orientation = null; this.Orientation = { NORTH: 0, EAST: -90, SOUTH: -180, WEST: 90 }; this.TrashType = { BLUE: 0, COMPOST: 1, GREY: 2, YELLOW: 3 }; this.leftKey = null; this.rightKey = null; this.gameover = false; this.score = 0; this.scoreText = null; this.highScoreText = null; this.msgText = null; this.continuePrompt = null; }; BasicGame.Game.prototype = { create: function () { this.lowestTrash = 0; this.lastLowestTrash = this.MAX_TRASH - 1; var trash; for (i = 0; i < this.MAX_TRASH; i++) { trash = this.game.add.sprite(this.game.world.centerX, -this.gap * (i + 1), 'trash'); trash.loadTexture('trash', this.rnd.integerInRange(0, this.MAX_TRASH)); trash.anchor.setTo(0.5); this.garbage.push(trash); if (i == 0) { this.lowestTrashType = trash.frame; } } var life; for (i = 0; i < this.lives; i++) { life = this.game.add.sprite(0, 0, 'life'); life.anchor.setTo(0.5); life.x = (this.game.width - (life.width / 2 + 10)) - (i * life.width); life.y = life.height - 10; this.lifeSprites.push(life); } this.sorter = this.game.add.sprite(this.game.world.centerX, this.game.height, 'sorter'); this.sorter.anchor.setTo(0.5); this.orientation = this.Orientation.NORTH; this.targetRotation = this.orientation; this.scoreText = this.add.bitmapText(25, 25, 'arialPixelated', '0', 16); this.scoreText.align = 'left'; this.highScoreText = this.add.bitmapText(25, 50, 'arialPixelated', 'BEST: ' + BasicGame.highScore, 16); this.highScoreText.align = 'left'; this.continuePrompt = new SuperBitmapText(this.game, this.game.world.centerX, this.game.world.centerY + 100, 'arialPixelated', 'RETRY', 16, 25); this.continuePrompt.anchor.setTo(0.5); this.continuePrompt.align = 'left'; this.continuePrompt.alpha = 0; this.continuePrompt.inputEnabled = false; this.msgText = this.add.bitmapText(this.game.world.centerX, this.game.world.centerY, 'arialPixelated', '', 16); this.msgText.anchor.setTo(0.5); this.msgText.align = 'center'; this.game.input.onDown.add(this.rotateSorter, this); this.game.input.onDown.add(function() {if (this.continuePrompt.isDown){this.game.state.start('Game', true, false);}}, this); this.leftKey = this.game.input.keyboard.addKey(Phaser.Keyboard.LEFT); this.rightKey = this.game.input.keyboard.addKey(Phaser.Keyboard.RIGHT); this.game.input.keyboard.addCallbacks(this, this.rotateSorter); //For mobile. Phaser.Canvas.setTouchAction(this.game.canvas, 'auto'); this.game.input.touch.preventDefault = true; }, update : function () { if (!this.gameover) { this.garbage.forEach(function(trash) { trash.y += this.fallSpeed; trash.angle += 0.25; }, this); if (this.garbage[this.lowestTrash].y > this.game.height - (this.sorter.height / 2.5)) { this.checkIfScored(); } } this.sorter.angle = Phaser.Math.snapTo(this.sorter.angle, this.rotationSpeed); if (this.sorter.angle != this.targetRotation) { this.isRotating = true; } else { this.isRotating = false; } if (this.isRotating) { if (this.clockwise) { this.sorter.angle += this.rotationSpeed; } else { this.sorter.angle -= this.rotationSpeed; } } }, resetTrash : function () { this.garbage[this.lowestTrash].y += -this.gap * (this.MAX_TRASH); this.garbage[this.lowestTrash].loadTexture('trash', this.rnd.integerInRange(0, this.MAX_TRASH)); this.lowestTrash++; if (this.lowestTrash > this.garbage.length - 1) { this.lowestTrash = 0; } this.lowestTrashType = this.garbage[this.lowestTrash].frame; }, checkIfScored : function () { if (this.lowestTrashType == this.TrashType.BLUE && this.orientation == this.Orientation.NORTH) { this.score++; if (this.gap > this.MIN_GAP) { this.gap -= 5; } else { this.gap = this.MIN_GAP; } if (this.fallSpeed < this.MAX_FALL_SPEED) { this.fallSpeed += 0.05; } else { this.fallSpeed = this.MAX_FALL_SPEED; } } else if (this.lowestTrashType == this.TrashType.COMPOST && this.orientation == this.Orientation.EAST) { this.score++; if (this.gap > this.MIN_GAP) { this.gap -= 5; } else { this.gap = this.MIN_GAP; } if (this.fallSpeed < this.MAX_FALL_SPEED) { this.fallSpeed += 0.05; } else { this.fallSpeed = this.MAX_FALL_SPEED; } } else if (this.lowestTrashType == this.TrashType.GREY && this.orientation == this.Orientation.SOUTH) { this.score++; if (this.gap > this.MIN_GAP) { this.gap -= 5; } else { this.gap = this.MIN_GAP; } if (this.fallSpeed < this.MAX_FALL_SPEED) { this.fallSpeed += 0.05; } else { this.fallSpeed = this.MAX_FALL_SPEED; } } else if (this.lowestTrashType == this.TrashType.YELLOW && this.orientation == this.Orientation.WEST) { this.score++; if (this.gap > this.MIN_GAP) { this.gap -= 5; } else { this.gap = this.MIN_GAP; } if (this.fallSpeed < this.MAX_FALL_SPEED) { this.fallSpeed += 0.05; } else { this.fallSpeed = this.MAX_FALL_SPEED; } } else { this.fallSpeed = 3; this.updateLives(); } this.resetTrash(); this.scoreText.setText(this.score); }, updateLives : function () { this.lifeSprites[this.lives - 1].loadTexture('lifeFull'); this.lives--; if (this.lives == 0) { this.gameover = true; this.msgText.setText('GAME OVER!\n' + this.score + ' responsibly disposed trashes!'); this.continuePrompt.alpha = 1; this.continuePrompt.inputEnabled = true; this.continuePrompt.input.useHandCursor = true; if (this.score > BasicGame.highScore) { BasicGame.highScore = this.score; this.highScoreText.setText('BEST: ' + BasicGame.highScore); } this.garbage.forEach(function(trash) { trash.kill(); }, this); this.game.input.onDown.remove(this.rotateSorter, this); } }, rotateSorter : function () { if (this.game.device.desktop && !this.gameover) { if (this.leftKey.isDown) { this.rotateLeft(); } else if (this.rightKey.isDown) { this.rotateRight(); } } else { if (this.input.y >= this.sorter.y - this.sorter.height) { if (this.input.x >= this.game.world.centerX) { this.rotateRight(); } else if (this.input.x < this.game.world.centerX) { this.rotateLeft(); } } } }, rotateLeft : function () { this.clockwise = true; switch (this.orientation) { case this.Orientation.NORTH: this.orientation = this.Orientation.WEST; break; case this.Orientation.EAST: this.orientation = this.Orientation.NORTH; break; case this.Orientation.SOUTH: this.orientation = this.Orientation.EAST; break; case this.Orientation.WEST: this.orientation = this.Orientation.SOUTH; break; } this.targetRotation = this.orientation; }, rotateRight : function () { this.clockwise = false; switch (this.orientation) { case this.Orientation.NORTH: this.orientation = this.Orientation.EAST; break; case this.Orientation.EAST: this.orientation = this.Orientation.SOUTH; break; case this.Orientation.SOUTH: this.orientation = this.Orientation.WEST; break; case this.Orientation.WEST: this.orientation = this.Orientation.NORTH; break; } this.targetRotation = this.orientation; } }; EDIT: My input listeners also get jacked up. I separate mobile and desktop but when the state restarts, my mobile listeners are firing when they shouldn't be because I am using desktop, not mobile.
  6. How do I create Start, Stop and Restart buttons? I'm learning babylonjs to teaching it for my physics stutents. My plan is to teaching to create physics simulations like phet colorado sims but in 3d. First, I need a standard GUI with Play, Stop and Restart buttons that works with physics engines. I made a playground for sample it: http://www.babylonjs-playground.com/#1ADV28#67 click two time run for wok after castor error. I want to stop the sphere free fall and restart the scene. Which functions or commands do I need to use for it? Thanks, Rafael J.
  7. Hi everyone, My first project and in desperate need of some help. My game starts and runs but doesn't restart? Is it because I need to re-initialize variables? Here's the code: http://pastebin.com/kYRLFqkb Thanks
  8. I'm working on a game where the player must complete a level within 30 seconds. If the player succeeds the timer is stopped, a message displays, the next level starts and the timer must be reset to 30 seconds. This all happens within the same Phaser.state. The time display only needs to be updated each second, not in between, so I looked at this example and use a time-object and initialise it with .loop() and then .start() it. When the time runs out or when player wins the timer is stopped with .stop(). The problem is that timer.Start() doesn't seem to work after the timer.Stop() was called. If looked at .pause() and resume() but I think(?) then it can potentially continue mid-second in the next level (time is very important in this game) not sure though.. Here's what I've got so far, I've isolated the code for the clock update in an example test program, see code below. var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); var clocktext; // bitmaptext var clocktimer; // Phaser.timer var clockseconds; // integer // ------------------------------------- // PHASER GAME FUNCTIONS // ------------------------------------- function preload() { game.load.bitmapFont('myfont', 'myfont.png', 'myfont.xml'); }; function create() { // add texts clocktext = game.add.bitmapText(160, 160, 'myfont', '---', 40); game.add.bitmapText(160, 160+80, 'myfont', 'Press R to reset timer', 40); game.add.bitmapText(160, 160+120, 'myfont', 'Press S to stop timer', 40); // timer object, note timer won't start running yet clocktimer = game.time.create(false); clocktimer.loop(Phaser.Timer.SECOND, updateDisplay, this); // handle keyboard keys R and S game.input.keyboard.onDownCallback = HandleKeyDown; clockseconds = 0; } function HandleKeyDown(e) { if (e.keyCode == 82) { initClock() }; // R = reset/init if (e.keyCode == 83) { stopClock() }; // S = stop/pause } function stopClock() { clocktimer.stop(); clocktext.text = "Stop at " + clockseconds + " seconds left"; console.log('stopClock - timer stopped'); } function initClock() { clockseconds = 5+1; // set countdown seconds, +1 because initial display will also decrease with 1 updateDisplay(); // initial display clocktimer.start(); } function updateDisplay() { // count down seconds clockseconds = clockseconds - 1; console.log('updateClock - seconds left: '+clockseconds); // check if time is up if (clockseconds <= 0) { // ohnoes! stopClock(); console.log('updateClock - time is up'); clocktext.text = 'time is up!'; } else { // update display var minutes = Math.floor(clockseconds / 60); var seconds = (clockseconds - minutes * 60); clocktext.text = "time " + (("0"+minutes).substr(-2) + ":" + ("0"+seconds).substr(-2)); }; } btw there's also this thread but that only explains how to start a timer, not how to stop and restart it.
  9. Hi, I'm new to Phaser and really like what I've seen so far. I'm using version 2.3.0 for testing out some ideas and noticed there might be an issue with the sound handling. On your demo page: http://phaser.io/examples/v2/audio/restart-sound If I click the screen multiple times, the audio is not stopped and started again. Instead, it launches more than one instance of the sound playing so I end up hearing a mix of all the previous sounds. However, if I set the version to 2.2.2 in the demo page, things seem to work just fine with multiple clicking. The sound is stopped and restarted and I hear only one instance playing. Is this a bug? Thanks, - Tim
  10. I am letting users select settings such as antialiasing on / off, canvas / webgl mode, and texture & physics-polygon resolution. To make these kick in, I am saving the desired settings to localStorage (done) and restarting the game via this function. function restartGame() { // Destroy the current game entity game.destroy(); // Boot a new game entity main(); }main() sets up the states again in a new game object and launches boot that launches preload and so on. This all works fine, but for one problem, when I switch from canvas to webgl renderer mode I get some screen artifacts (white quad in the bottom-right) and the screen freezes, no javascript error though. EDIT: The problem doesn't seem to happen when going from canvas -> webgl, but also when going from canvas -> canvas. So it probably has something to do with destroying a game using a canvas renderer. Is there a more built-in way of restarting the game, or is it possible to change renderer & antialiasing on / off without restarting?
  11. Hi all I have a big problem: At the game over scene which is in the same of the game state, i have two button replay and main menu When i click replay which have the function: The state restart but when i click at the place where the button was, the state restate again. I think that the button is not destroyed just the sprite which is destroyed, i have tried button.kill() and button.destroy() before restating state but i get an error. And when i do : I get an error of an undefined velocity ......., The question is, is there any way to restart the state like if it's the first time the state is started ??
  12. Howdy all Does the Phaser.Text.destroy() method actually work? I'm testing in v2.0.7, and I've found that by adding a just a single Phaser.Text object, if I then restart current State many times, the memory skyrockets. Yes, I'm using a shutdown method, and I'm calling destroy and setting the phaser text object to null. But no dice. If I test the same code without creating the Phaser.Text object, the restart is fine, no crazy memory usage. I created a small test game that shows to bug reliably on my PC, can be seen here: http://phasertext.parseapp.com/ Two options are available, you can start the Game State with or without a Phaser.Text object being created. The Game State then has a 5 second timer and will do a restart 10 times. Little bit of info in the Console Log. Testing in Firefox and checking its total memory usage: - Without Phaser.Text memory bounces between 350 to 450mb during the 10 restarts. - With Phaser.Text memory skyrockets to 2 gig after 10 restarts and never comes back down until the tab/window is closed. Once closed, GC eventually kicks in and the memory settles back down to 300mb. Before and after each test, I shutdown Firefox. During the test I only have the one tab open running the game. The Game State code is below. The creation of a Phaser.Text object is driven by the setting of boolean BasicGame.createText when the Game State is started from the MainMenu (MainMenu code not shown, can be seen in test app via debug). BasicGame.Game = function (game) { // When a State is added to Phaser it automatically has the following properties set on it, even if they already exist: this.game; // a reference to the currently running game this.add; // used to add sprites, text, groups, etc this.camera; // a reference to the game camera this.cache; // the game cache this.input; // the global input manager (you can access this.input.keyboard, this.input.mouse, as well from it) this.load; // for preloading assets this.math; // lots of useful common math operations this.sound; // the sound manager - add a sound, play one, set-up markers, etc this.stage; // the game stage this.time; // the clock this.tweens; // the tween manager this.world; // the game world this.particles; // the particle manager this.physics; // the physics manager this.rnd; // the repeatable random number generator // You can use any of these from any function within this State. // But do consider them as being 'reserved words', i.e. don't create a property for your own game called "world" or you'll over-write the world reference.};BasicGame.Game.prototype = { textStyle: null, phaserText: null, restartCounter: 0, create: function () { this.game.physics.startSystem(Phaser.Physics.P2JS); this.game.physics.p2.updateBoundsCollisionGroup(); this.game.physics.p2.setBoundsToWorld(true, true, true, true, false); this.game.physics.p2.setImpactEvents(true); this.game.physics.p2.gravity.y = 500; this.add.sprite(0, 0, 'gamepage'); //create a bunch of P2 boxes to cause lots of collisions and put a bit of load on the game this.boxes = this.game.add.group(); for (var i = 0; i <= 20; i++) { var box = this.game.add.sprite(100, 100, 'box'); this.game.physics.p2.enable(box); this.boxes.add(box); } this.textStyle = { font: "24px Verdana", fill: "#000000", align: "center", stroke: "#000000", strokeThickness: "2" }; if (BasicGame.createText) { this.phaserText = this.game.add.text(100, 150, 'Phaser.Text', this.textStyle); } if (this.restartCounter < 10) { //do 10 timer based restarts this.game.time.events.add(Phaser.Timer.SECOND * 5, this.restartFromTimer, this); } else { console.log('*** All timer based restarts completed ***'); } }, update: function () { }, restartFromTimer: function() { this.restartCounter++; console.log("*** Timed restart number: " + this.restartCounter); this.restartGame(); }, quitGame: function (pointer) { this.state.start('MainMenu'); }, restartGame: function (pointer) { this.state.restart(); }, shutdown: function() { console.log("Shutdown"); this.textStyle = null; if (this.phaserText != null) { console.log("phaserText destroy"); this.phaserText.destroy(); this.phaserText = null; } this.boxes.removeAll(); }};
  13. How would I go about detecting collosion of a player and a block(image)? The player currently collides with the block but I want to know how I could restart the game after this happens.
×
×
  • Create New...