terencechow Posted January 16, 2015 Share Posted January 16, 2015 I upgraded phaser to 2.2.0 last month which fixed an internet explorer specific bug. I was handed off a game someone else started developing so I don't know the ins and outs of the code entirely. I kept developing thinking nothing else had changed after upgrading. (I had to replace game.time.now with game.time.time and also had to replace methods justPressed to downDuration) Besides that, there were no other changes that related to upgrading phaser. What I didn't notice however was that something had happened in my game. Specifically, the update function is being run multiple times with 0 ms in between. To me, that tells me the update function is run twice or three times in the same instance. Wtf??? How and why? I noticed this when I added a counter to my update function as well as a timer to track how long since the last update. The code at the top of my update function looks like this://updateCounter is initialized at 0 outside the update functionconsole.log(this.updateCounter,this.game.time.elapsedSince(this.timeSinceLast));this.updateCounter +=1;this.timeSinceLast = this.game.time.time;My console outputted things like this: 0 600 <--nonsensical first result because first result has timeSinceLast = null1 172 03 04 205 06 07 168 09 16 etc etc As you can see, my update function is getting called sometimes 2-3 times with 0 ms in between. This shows up more in mobile. In desktop, I see something closer to 1 172 03 174 05 176 167 08 169 010 17 which still appears to be calling the update function twice at the same moment... When I reverted back to the prior version of phaser I noticed the counter and timer being much more logical: 1 162 163 174 165 176 16 etc etc Is there a reason that upgrading phaser would have done this? Was there some logic in an older version of phaser that was required, that during an upgrade was no longer necessary and is now being duplicated in my code? Link to comment Share on other sites More sharing options...
Recommended Posts