Jump to content

Fastforward button


farzher
 Share

Recommended Posts

I' m not sure you can achieve that effect this way. Even if you can do all of the update calculations multiple times per frame that would be a heavy load and paradoxically slow it all down.

I'd have thought that you need to actually increase the movement speed of sprites etc either by increasing the amount they move per update or shortening the time on Tweens. Probably by having all of these numbers defined by a variable that you change in a function that is called when you start fast forward.

Link to comment
Share on other sites

I'm surprised this is apparently so difficult to do in Phaser.

 

Even if you can do all of the update calculations multiple times per frame that would be a heavy load and paradoxically slow it all down

 

 

That's fine, I don't care if you need a powerful machine to fastforward faster.

I need everything to be frame perfect, so I can't mess around with speeds. My game doesn't run on delta time or anything like that, it's just frame by frame updates.
 

Link to comment
Share on other sites

I'm far from an expert so I may be wrong but as far as I can tell Phaser can only refresh the screen as fast the browser allows which I think is 60fps.So going above whatever this refresh rate is wouldn't work.  Therefore you're asking it to calculate the whole screen multiple times in a frame and only displaying the last one.  EG if a sprite moves left to right at sprite+=2 you're getting it to do that say ten times in a frame which will move it 20 to the right.  As the screen can only refresh once in this frame the sprite will appear to jump visibly by 20 on each frame but you'e asking the computer to do this in 10 steps alongside calculating everything else all in one frame.  That just seems a big ask to me on any machine.

 

I know that physics and the display framerate are decoupled in the latest version of Phaser but I can't see how that would help.  Are you experienced in languages closer to the metal?  Is the technique your suggesting for fastforwarding the game the one that a game written in, say C++, would use?  Just curious if this is the case for more powerful platforms.

 

Anyway sorry its only some thoughts and not a solution.  I've responded because I thought it was an interesting question and I tried to think how I would do it and offer this as part of a discussion to maybe help jog a thought or idea.  Other users on this forum, such as Rich or Lewster32, would be much more able to give a definitive answer on this.  WIth a bit of luck they may see this thread.  Good luck.

Link to comment
Share on other sites

What you're saying makes sense.
But if I fast forward like that, it'll slightly change gameplay (bullets will skip more space per frame and have a chance to go through targets, etc).

The only way to keep it totally consistent is to update the game logic multiple times per frame.
But Phaser hides how that works and updates gameobjects on its own.

I guess I'll check out the source code and see if I can hack it to update objects more often.

 

Link to comment
Share on other sites

I simply put

game.update(200);

As the first line of my update function. Obviously I'm not supposed to do that considering Game's update function is protected. But javascript lets me do whatever I want.
200 is what it thinks is the ms since last frame. Idk how this doesn't infinite loop (I'm calling update in update), but this seems to work.
If anyone finds a less hacking way of doing this though let me know.

Link to comment
Share on other sites

I am also interested. :) My problem is that since the arcade (or any other physics engine included in phaser) engine does not support continuous collision detection, which leads to objects falling through each other sometimes (most notably the player falling through the floor). My reasoning is that if I update the game logic to update more often, it will check for collisions more often, hopefully stopping the collision-problem. Is that wrong?

 

Edit: Ok, I actually AM wrong. The above method (game.update(200);) does execute the update function more often (not sure what really happens,

this.game.time.elapsed

showed nothing but 0.).

The problem for me is that it does not only run MY update code, but all of it, including drawing the sprites - just everything. FPS go way up. So for me, that's not really what I was looking for, since I just wanted to have more frequent collision detection. *sigh*

Link to comment
Share on other sites

Not sure where it is but I think I remember seeing somewhere in Phasers docks a way to speed up the game. I think its under the time section, I'll see if I can find it and update this post if I do.

 

Edit: No, maybe not I must be getting confused with another framework.

Link to comment
Share on other sites

Yeah, I wasn't quite sure what it did but it didn't render more FPS. Learned that today and was very confused for a while since changing the game.time.desiredFPS didn't chance game.time.fps.So as far as I can see the name "desiredFPS" is a bit misleading, FPS usually being the amount of frames drawn per second (hence the name :D), not the amount of update loops.

 

P.S.: maybe a bit of a funny story: Since I wanted to up physics calculations per second, I set desiredFPS to 120 and tried my best to handcode some sort of slowing mechanism for the FPS through locking framerendering for a certain amount of frames (half of them at desiredFPS = 120) by toggling game.lockRender true/false. Later of course it turned out that all of this was useless since phaser already handles that.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...