Search the Community
Showing results for tags 'reset'.
-
Hi, Is there any method to reset an emitter properly to be reused ? because i reuse a set of emitters but sometimes when i reuse a previously used emitter it show quickly his last state (repartition of particules in their last coordinates) and then restart his animation, so i wonder if is it a bug or a bad use. EDIT : It's a bad. Code used to instanciate the emitters in the poolEmitter (extended Phaser.group) instance : em = game.add.emitter(10,16,30) // some emitter settings (minRotation, setXSpeed,makeParticles...) em.kill() this.add(em) Code used in the poolEmitter instance to get a free (dead) emitter : let obj = this.getFirstDead(false) obj.revive() obj.x = x obj.y = y return obj Code used for exploitation of the emitter : let em = poolEmitter.create(player.x ,player.y) em.explode(800,30) setTimeout(function(){ em.kill() em.on = false em.visible = false /* em.forEach(function(p) { // I try this to hide the particule manually to avoid to be showed in their last coord when reuse the emitter, but dont work p.alpha = 0 })*/ },900) Thanks
-
Hello evryone Sorry in advance for my bad english; I wanna ask somthing about .ArcRotateCamera (); I want to make camera with locked position behind the player when the player moving but if player stand on the place he can moving around with the camera and when he again start moving the camera smoothly rotating to the locked position. I wondered if I will make somehow the camera will checking position.z of the player then camera will be calculate position behind the player. Here is my player how move in game for better understending: http://www.babylonjs-playground.com/#TGA1QA By the way I only want some tips or show me a way how I can make this work out I want to fully understand how javascript and babylon.js works. Thank you.
-
Hey i'm doing a small project in which, when i click on an object the game resets: positions, timers, everything goes back to the same way it was when it was first opened. Is there a way to do this? Something like game = new Phaser.Game(config) ?
-
I am clearing my scene entirely, where I use completely new sounds and new plans/textures. What is the proper way to do this? I'm first going through each of my planes and removing the plane and animations for each of them: item.plane.dispose(); item.animateR.reset(); item.animateX.reset(); item.animateY.reset(); and do the same for the sounds. Then I go to the scene and do the following: scene.dispose(); scene.disposeSounds(); The problem is I still see a lot of memory being used up, even after I do this and have an empty canvas on the screen. Am I missing a step or going about this wrong? Thanks, Jeff
-
I have set up a function that checks if "X" is alive and if it is alive it kills it and then spawns it. However when I used kill() it didn't actually kill him. However when I set destroy it would kill him. Only that way could I spawn him again. Why is that?
-
Hey all! I'm having an issue where i'm trying to reset the player sprite, but it doesn't do anything, and the console yields no errors and i know i'm trying to reset the right thing. I recently grabbed a copy of Phaser 2.5, and yet if i switch back to the older phaser i was using (2.4.4) the reset i have works correctly. I'm a little stumped on what I'm missing here, any help would be appreciated!
- 2 replies
-
- phaser 2.5
- reset
-
(and 3 more)
Tagged with:
-
hi there, im trying to erase a part of the bitmapdata canvas ( a blue rectangle) with the mouse. but want to know how i destroy it or reset it to bring the solid rectangle solid again without any holes (made with the mouse) any ideas? i tried .destroy() but seems that doesnt help
- 1 reply
-
- canvas
- bitmapdata
-
(and 1 more)
Tagged with:
-
Hello, I have been trying to figure something out for a while now. So, I have a player who catches things from above, once he catches something it gets stacked on his hand. Those things which are stacked are in a group called Slices. What I want to do is when the player hits the number of 3 Slices the group gets reset back to 0 (so there would be no more stacked slices) and then continue with the stacking from 0. Sorry if the explanation is bad :\ I will try to clear it out more if you have any questions Thanks!
-
Hello, I have been trying to figure something out for a while now. So, I have a player who catches things from above, once he catches something it gets stacked on his hand. Those things which are stacked are in a group called Slices. What I want to do is when the player hits the number of 3 Slices the group gets reset back to 0 (so there would be no more stacked slices) and then continue with the stacking from 0. Sorry if the explanation is bad :\ I will try to clear it out more if you have any questions Thanks!
-
I'm making a game where a function creates a group of "fish" with tweening, and the tween calls another function on completion to create a new tween with new parameters, and so on. When the player's character collides with the fish, I want them to reset, and swim using a new tween. All the code works except that the tween that was in action prior to collision isn't destroyed by .reset function, and most likely is the reason why the fish are jumping around the screen. Here it is: http://chetansharma.info/work/thefishking/v02/ How do I address or stop a tween when I can reference the object it was applied to? I tried creating a tween manager and added all tweens to it (inside a state's declaration) but keep getting errors (in game.js state file) An example on how to solve this would be nice.
- 1 reply
-
- tween
- tweenmanager
- (and 5 more)
-
I'm making a game where a function creates a group of "fish" with tweening, and the tween calls another function on completion to create a new tween with new parameters. When the player's character collides with the fish, I want them to reset, and swim using a new tween. All the code works except that the tween that was in action prior to collision isn't destroyed by reset function, and makes the fish jump around the screen. How do I address or stop a tween when I can reference the object it was applied to? I tried creating a tween manager and added all tweens to it (inside a state's declaration) but keep getting errors.
-
- tween
- tweenManager
- (and 4 more)
-
Hello all, I am trying to basically stop my Phaser game completely, the main thing is getting it to stop "updating". I'm not sure how to do this. This is my code creating the game: game = new Phaser.Game(1000, 600, Phaser.AUTO, "gameCanv", { preload: preload, create: create, update: update, quitGame: quitGame } ); In the quitGame function, I am trying to stop the game from running, so I can see if the user got a high score, update the scoreboard for it, and ask the user if they want to play again with different conditions. I have this code for that function: function quitGame(){ console.log("in quitGame"); ingredient.kill(); chef.kill(); score = 0; gameOverOne();} //end quitGame function Please help... Thank you!
-
Hi all, I'm having a problem where I need to reset the game.input.onDown event in the same way as Phaser.Key.reset. As you can see in the docs, that particular method is useful for resetting a key's state. I want to do that same sort of thing with the click / tap event. Here's effectively what I'm wanting, in pseudo code: this.game.input.onDown.add(foo);...this.game.input.onDown.reset();Is something like this possible to do?
-
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.