Search the Community

Showing results for tags 'state'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 74 results

  1. Same background image in all states

    Hello, I'm new to the Phaser framework and I'm trying to have a single backgound and logo througout all the states in a phaser game. I add the background image in the very first state but when I start the next state using:"State2"); the background image disappears. Do I have to load the background image in every state? Thanks
  2. Any Pause Screen Code / Examples?

    Hi guys – just discovered Phaser yesterday. Just wondering if anyone has an example of a pause screen/state in a game created? Would be great to see some code. Had a look at the examples in the docs and couldn't see anything. Also, is the only way to pause/resume a game to individually pause and then resume all the moving / relevant elements, or am I missing some amazing game.pause() function? I pretty familiar with JS, but am pretty much a noob at creating games with frameworks. Many thanks, Shaun
  3. probelm with weapon

    Being rather new to Phaser I have run into a problem that have halted my progressed. The code in question is as following. //Gun this.weapon = game.add.weapon (20, 'missile'); this.weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; this.weapon.bulletAngleOffset = 0; this.weapon.fireAngle = 0; this.weapon.bulletSpeed = 400; this.weapon.fireRate = 100; this.weapon.trackSprite(sprite, 90,52) And it gives me the following error TypeError: Phaser.Weapon is undefined In my test project I have the exact same piece of code, the only difference is that my current project uses game states and the previous is contain in a single .js file Anyone had a similar error and/or have a solution? I have added the project as a .rar file in case that helps Heli-cop hero opgave_2.rar
  4. Restart state but keep saved variable?

    I'm doing a round based game. So after you've killed so many enemies it'll pop up, "Round 1", after some more, "Round 2" and so on. The amount of enemies doesn't change it's just the round that increases after you've killed say 20 enemies. I have a current variable at the top of my game.js file var currRound = 1; var EnemiesKilled = 0; Every time I kill an enemy I increment up the variable then in one of the collision handlers I do if EnemiesKilled == 20 then show some text newLevel.setText("Woo!! Round " + currRound + "!"); and restart the round via setTimeout(function() { game.state.start(game.state.current); }, 1000); The thing is, it whipes the variable of EnemiesKilled. How can I keep that variable so I always know how many enemies the player has killed?
  5. Audio + memory usage = headache

    Does anyone know how to unload and destroy audio files appropriately? I have about 12 MB of audio in my game, or about 15 minutes. I do not load all of them at one time, since this will break any mobile browser. So I load them in the states they are needed. About 4 MB is loaded at the same time. According to the Task Manager in chrome, the memory used by my game just keeps growing and growing, easily above 1000MB by changing states. (Browsers decode audio to lossless => memory use is high, regardless of file format and encoding.) In all states I have a shutdown function that destroys all the sounds and purges audio loaded in the cache. This is my current code (very similar to how cache is cleared when changing states, but I have some assets I use everywhere and don't want to remove): function clearCache () { // Purge sound. var key = this.sound._sounds.length; while (key--) { this.sound._sounds[key].destroy(true); } // Destroy "everything" in cache. for (var i = 0; i < this.cache._cacheMap.length; i++) { var cache = this.cache._cacheMap[i]; for (key in cache) { if (key !== '__default' && key !== '__missing' && this.cache._doNotDelete.indexOf(key) < 0) { if (cache[key].destroy) { cache[key].destroy(); } delete cache[key]; } } }}(Note: This problem did not occur in previous Phaser versions, so I am suspecting that some reference to the audio files are lingering, but can't find out where.) Also, if anyone has a good way of profiling and debugging browser audio, please share, I haven't found a good way to figure out where all this memory goes (Chrome heap profiler says that I use | 20MB).
  6. Hi all, currently I got problem that I have a websocket thread to communicate with the server. and the game object is also start in the process, the situation is like this. when I got the response: A from the server, I will change the game to a new state by game.state.start('NEW STATE'); and then I will get the response: B, C from server, then I need to run some functions defined in the new state, like this game.state.callbackContext.function_in_new_state(); but it is not working, then I loged the state game.state.current I found that the current state is still the OLD ONE. I know the state change need some time, BUT is PHASER provide any callback method when the current state changed to another one, thx everyone.
  7. Hello :), i am facing an the following issue: How do i preserve my sprites, buttons etc. after switiching back from another state. Example: 1. First State: I have several sprites, which i drag an drop around, draw some lines etc. The moment i click on a certan button State 2 is loaded up Sso when i go back to State 1 from State 2,everything is resetted and my sprites are at the wrong place etc. Question: What can i do about it? greets and thanks
  8. Hi, I am new to game development and am trying to make a game where one stage has 6 characters and user can choose any number of characters from here and only those characters will be loaded in next stage. I am using different js files for each stage. Please help. Thanks in advance
  9. Hi there, Can anyone tell me what I'm doing wrong here? I just need an array of sprites with inputOver events. Right now it works on the first load of the menu and not thereafter. It needs to load 4 times in the game. Currently I'm doing this: var createPanels = function(){ // draw panels for (var i = 0; i < 4; i++) { lightPanels[i] = game.add.sprite(ProgressModel.gameRooms[i].x * game.width, ProgressModel.gameRooms[i].y * game.height, 'room-light-' + (i + 1)); lightPanels[i].name = i; lightPanels[i].inputEnabled = true; lightPanels[i].events.onInputOver.add(over, this); lightPanels[i].events.onInputOut.add(out, this); lightPanels[i].events.onInputDown.add(selectRoom, this); lightPanels[i].events.onInputUp.add(Up, this); } }; How should you create sprites in an array with events that are reusable on subsequent state loads? There are no errors, the inputOver event just doesn't fire (the input down works fine every time) Any input is much appreciated. Thanks, H
  10. Need help with states and text

    Hay guys, trying to learn states and i've run into a problem. I've got this function. And when it is called, i need it to create some text. States and breaking my phaser game into several files is a first for me and i cant for the life of me figure this out. I need to create some text from the animationPass function, but i get this error: Uncaught TypeError: Cannot read property 'text' of undefined -- of line 7, and thats where the create introText line is. in my intro.js i've got function animationPass() { introText = this.add.text(320, 240, 'Write some text'); //i've tried this.introText - but that didnt work either. } var introMap = function (game) { var introText; } introMap.prototype = { create: function () { animationPass(); }, update: function () { } } And this has worked fine so far. Infact i've used this structure in another file and it works just fine there. Here i get however Uncaught TypeError: Cannot read property 'text' of undefined -- of line 7, and thats where the create introText line is. My preload.js looks like this preload = function (game) { WebFontConfig = { google: { families: ['Press Start 2P'] } }; } preload.prototype = { preload: function () { this.load.spritesheet('intro', 'img/introAnim.png', 172, 124, 25); }, create: function () {"introMap"); } } I humbly ask for your assistance. And i'm sorry if the answer is obvious. I would not ask if i hadn't spend a great deal of time trying to figure out the answer myself.
  11. I would like to prevent players from switching to any game state by typing "game.state.start('name');" into the console. Has anyone found a way to prevent this from happening? Imagine you have a login-screen and any user can just type "game.state.start('play');" into the console and skip straight into the game. I have already tried using anonymous functions and closures but the problem is that the other states such as BootState, MenuState, GameState etc cannot access the game object created from new I cannot be the only one who's worried that users can simply skip any game state by typing one line into the console. How have others dealt with this security breach? I tried googling but couldn't find any posts about this whatsoever. Thanks in advance for all answers!
  12. change state issue

    when i switch from menu state to game state and return at menu, the animation of star field that i have created is stopped. i post my code here: create: function(){ //create a 100 stars in random position this.sprites =; for (var i = 0; i < this.max; i++) { this.xx[i] = Math.floor(Math.random() *; this.yy[i] = Math.floor(Math.random() *; var[i], this.yy[i], 'star'); this.sprites.addChild(star); this.stars.push(star); } // [....] other code }, update: function() { // shift the star at left for (var i = 0; i < this.max; i++) { this.xx[i] -= this.speed; if (this.xx[i] < 0) //return at right and give a new random y { this.xx[i] =; this.yy[i] = Math.floor(Math.random() *; } this.stars[i].x=this.xx[i]; this.stars[i].y=this.yy[i];//apply a new coords } } }; function play(obj) {'Game'); }
  13. 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 = []; = 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 =, * (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 =, 0, 'life'); life.anchor.setTo(0.5); life.x = ( - (life.width / 2 + 10)) - (i * life.width); life.y = life.height - 10; this.lifeSprites.push(life); } this.sorter =,, '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(,, + 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(,, 'arialPixelated', '', 16); this.msgText.anchor.setTo(0.5); this.msgText.align = 'center';, this); {if (this.continuePrompt.isDown){'Game', true, false);}}, this); this.leftKey =; this.rightKey =;, this.rotateSorter); //For mobile. Phaser.Canvas.setTouchAction(, 'auto'); = 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.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.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.MIN_GAP) { -= 5; } else { = 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.MIN_GAP) { -= 5; } else { = 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.MIN_GAP) { -= 5; } else { = 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.MIN_GAP) { -= 5; } else { = 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); } }, rotateSorter : function () { if ( && !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.rotateRight(); } else if (this.input.x < { 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.
  14. HI, I am beginning with Phaser development and started to read Interphase. Is it possible to re-use UI components in between states? I see that it is possible to pass data to the next state but somehow it is not really working for me. I have this in one state: gengine.IntroScreen = function(game) { this.exit; }; gengine.IntroScreen.prototype = { preload: function () { exit = this.load.image('exit', 'assets/shared/exit_sprite.png'); }, create: function () { this.exit = this.add.sprite(940,20,'exit'); this.exit.inputEnabled = true;, this); }, exitState: function() { // restart the game this.state.start('boot'); }, So the exit sprite is wired to a function that resets the game. Eventually I switch state in my code, trying to pass the exit sprite to the next state: this.state.start('next_state', false, false, this.exit); So then I was testing that in the next state, the sprite image was there since I didn't clearWorld() but it no longer responds to any click events. Is it better to just rebuild the UI every time from scratch? Thanks
  15. I was wondering is there function in Phaser that will allow me to generate pixel data object from current Phaser Scene (cover the whole canvas or part of it) and pass this object in I don't know which form to the second Phaser Stage and display it as it is at certain position? Something like this: Or I just fall back to plain Canvas API and use ImageData object?
  16. Hi people, I've recently just started using the Phaser framework 2 days ago and I am developing my first game, an RPG with phaser...I recently just ran into an issue in my character select state where my scope(this) becomes the window scope and does not recognize my internal functions. Any insight on my issue would be extremely helpful. thank you!!!
  17. ok. I have same problem in there: I am digging all documentation and examples for solving that problem. But i have nothing really. I can post my own codes if anyone want. And that example: Its including same problem. If you run it carefully, you can see first place objects colliding world bounds, but after changing state its not colliding.
  18. Hello forum I am writing a game using phaser v2.4.8 which has several states. The general structure of my game is: Level list - the player can select a level to play on a draggable background Level - each level consists of 5 puzzles (mini games) Puzzle - each puzzle is a state I am fairly new to javascript and phaser (but not to programming or scripting languages). Enough introductions - after watching several phaser tutorials I just couldn't understand why states are defined in the following way: game.state.add('Boot', Game.Boot); ... //in a separate Boot.js file: var Game = {}; Game.Boot = function(game) { this.someVariableName = ...; ... }; Game.Boot.prototype = { preload: function () { this.add.image(...); ... }, create: function() {...}, ... }; Whereas my states are written as so: game.state.add('Boot', BootState); game.state.add('Preload', PreloadState); ... //in a separate js file: var BootState = { preload: function() { game.add.image(...); ... }, create: function() {...}, ... } //in a separate js file: var PreloadState = { preload: function() { game.add.image(...); ... }, create: function() {...}, ... } My questions are: What is the purpose of the 'game' parameter in Game.Boot = function(game) {...} ? Is the game object automatically passed as an argument in game.state.add('Boot', Game.Boot) ? Is there any reason for me to use the first approach instead of the other one? What are the differences? Thank you in advance for your responses Force out
  19. Black flashes between game states

    Hi, I've encountered a strage problem while building a little, mostly static mobile game using Intels XDK, Cordova and Phaser (2.4.6). It's targeted at Android and uses the Crosswalk web runtime. I basically followed Matt McFarlands menu tutorial, and created States to do stuff like booting up, loading all assets, showing a splash screen, showing a menu, the levels etc. I'm using one Phaser.Graphics object per State to draw on (my game only needs a few geometric items). Additionaly I'm using the SaveCPU plugin to avoid unnecessary render cycles. Unfortunately removing it doesn't seem to remove the flashing problem. The stage.background is set to white, in the HTML part backgroud colors are also set to white. When moving from one State to the next I nevertheless get strange black flashes after entering the new State. Sometimes they cover the whole viewable area, sometimes they seem to be a black rectangle originating at the canvas center and covering only the lower right quadrant. I only get those flashes on mobile devices, they don't happen in a browser on a PC. I also observed that they seem to appear only after I add the Graphics object to a State, States whithout Graphics objects don't flash. Unfortunately I wasn't able to find out when exactly a flash occurs, but it seems to be either in or before/after init(), preload() or create(). The typical structure of my States looks like that: MyState = function () {} MyState.prototype = { init: function () { game.stage.backgroundColor = "#FFFFFF"; =, 0); // do some more stuff, initialise variables etc. }, preload: function () { = 0; =; =; // do some more stuff }, create: function() { // do some more stuff game.add.existing(; // do some more stuff, set up input handlers etc. // graphics fade in game.add.tween({alpha: 1}, 1000, Phaser.Easing.Quadratic.Out, true); // rendering was set to 60 FPS in the previous state (probably unnecessarily), // as long as there are active tweens forceRender() of the SaveCPU plugin is called in update() = 0; }, update: function () { if ( === 0 && game.tweens.getAll().length > 0); }, render: function () {; // draw stuff like menu buttons game pices etc using graphics drawing methods }, // [ ... more methods for state specific stuff ... ] moveToNextState: function (stateName) { // fade out the graphics and move on to the next state = 60; var theEndTween = game.add.tween({alpha: 0}, 1000, Phaser.Easing.Quadratic.Out, true); theEndTween.onComplete.add(function () { game.state.start(stateName, true, false); }, this); } } So I wonder if anybody has an idea about what causes the flashes and how I may avoid them?
  20. Draw data table in a scene

    Is there some plugin or some tool inside Phaser that can help me draw a table of data. I have this image: As you can see I have two arrays of data and they are drawn in Phaser text field as string, but since the numbers inside are of different string length points array is longer than errors array and therefore cut if over the screen boundaires. How can I draw a table with this data, 3 rows by 15 columns? Also could I possibly create such plugin for Phaser?
  21. Switching states - error [REMOVE PLEASE]

    Hello, I'm having a problem when switching states with Phaser. I have one menu state and one game state. In menu there are different options and different sub-menu options. Something like this: menu: MenuOption1 - click calls function menu1Submenu() which creates sub menu which is overlayed over part of the Menu MenuOption2 MenuOption3 I set groups and images inside menu1Submenu function this way: this.menu1SubmenuGroup1 = this.menu1SubmenuGroup1 ||; because you can go back and fort however you want I don't want to create a new group for submenu content everytime - when I already created one before. So I just change renderable to false/true instead and change inputEnabled to false/true depending whether the submenu is active or not. One of the options in submenu is to start the game (thus changing states occurs). I first remove all events I set on all elements of my groups which I created then destroy them and the destroy group as well, to make sure everything is clean I set all the groups to undefined. Then I change state: this.start.state('game'); In the game I have a button which leads back to menu, that buttons simply does: this.start.state('menu'); When I get back to menu animations start, everything seems ok but the moment I click on MenuOption1 to open submenu nothing happens or more precisely when I comment destroying, removing events and setting all groups to undefined I get errors: phaser.js:40129 Uncaught TypeError: Cannot read property 'events' of nullPhaser.InputHandler.start @ phaser.js:40129Phaser.Component.InputEnabled.inputEnabled.set @ phaser.js:45418(anonymous function) @ menu.js:1323Phaser.Timer.update @ phaser.js:65567Phaser.Time.update @ phaser.js:64890Phaser.Game.update @ phaser.js:35146Phaser.RequestAnimationFrame.updateRAF @ phaser.js:60028_onLoop @ phaser.js:60012 83 phaser.js:40273 Uncaught TypeError: Cannot read property 'scale' of null When I set my groups as: this.menu1SubmenuGroup1 =; Everything works ok, but even when I destroy groups and all their content and set the property to undefined it brings this error. Could someone advise me how to remove the stuff properly in this case? I want to keep the groups but don't want to have them declared before because that just adds more content which is needed most of the time (imagine that you don't always open settings, and so on so there is no need to create them all the time), and I also don't want to stick only to this.menu1SubmenuGroup1 =; because this way everytime anyone clicks on any option adds more groups to phaser object (correct?), so a few times clicking back and forth can give dozens of groups which all link to same object (?) or at least polute the memory (I suppose I could always destroy groups set undefined when going through menu but that doesn't seems as a nice effective way). I'm not sharing the entire code because it's too long and I managed to reduce the problem to lines mentioned above. Thank you very much I really appreciate any advice. PS: I used latest stable Phaser version 2.4.7.
  22. I get a error when I use game.state.start() function in phaser.min.js 2.4.6. I want back to previous state(in my code ,it is "Main" state) with a button tap function in "Play" I use the code:game.state.start("Main").but there throw a error:Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D'. It seems like that the preload function in "Main" state been called again,because the game run well when I replace the code to : game.state.start("Main",true,true).In fact ,I must keep the game.Cache in game ,so the gamer woudn't wait for a long time. Who can help me?Thanks to any replies!
  23. Timer at beginning of state

    Hello everyone, I am trying to create a timer that will count down three minutes after the state was started. I am not sure how to make a text that will visualize the timer.(00:00) Can you guys help out?
  24. So I want to make states which can have custom constructor parameters of some sorts. This is my testState: export class TestingState extends Phaser.State { constructor(firstVar: any, secondVar: any, thirdVar: any) { console.log(firstVar); console.log(secondVar); console.log(thirdVar); super(); } } The firstVar is always the Phaser.Game variable, but the second and third are supposed to be custom parameters. I start my state like this:'testState', GameStates.TestingState, false);'testState', false, false, 'Hello', 'test'); The firstVar just logs the Phaser.Game and the second and third print out undefined. But if I remove the 'test' argument, it doesn't log anything the third time.