Delayed Lag for Drawing Event

Rainbros

  • Posts: 175
I have an actor that has an attribute "angle" that is incremented in the "when drawing" event as long as the enter key is down. Then I have a line being drawn that just shows the angle as it changes.

What I don't get is that when I first press down enter, the line sweeps around smoothly for a short time, but then it starts to kind of slow down and look really laggy. I release enter and press it down again, same thing. - smooth then laggy.

But if I move the same code into the 'Updating" event, there is no lag.
EDIT: It seems to me now that there is a similar lag even when using "updating", but it's less obvious. I've noticed this using the 4-way movement behavior. The actor moves smoothly at first but then starts to lag a bit.

Is there an explanation for this? I've attached the test file below.

« Last Edit: October 07, 2016, 05:58:52 pm by Rainbros »

Justin

  • *
  • Posts: 4007
I'm not seeing what you described, but I can take a guess as to why it might happen to you.

The drawing step doesn't have a fixed time step. It tries for 60 FPS, but if the game isn't keeping up, drawing can happen less than that. So if the game dips below 60 FPS, any logic you have inside the drawing event will happen less frequently.

The update step, on the other hand, pretty much always happens 100 times a second. If you set the angle in the update step, it should keep going in a smooth circle even if a few frames are dropped.

That said, I'm a bit dubious as to the validity of my own explanation, because it seems odd that you would see any drop at all in FPS for such a simple scene.

For Live Support: Join our discord channel and ping me @justin.

Rainbros

  • Posts: 175
Really, it looks completely smooth when you run it? Weird.

Yeah, that might make sense, but like you said, it just doesn't really add up in this case. And I don't see how that would explain why it's always smooth for me at first.

Rainbros

  • Posts: 175
Were you testing in Flash browser? Because I just tried that, and it seems the lag only occurs in the Flash player.

Justin

  • *
  • Posts: 4007

For Live Support: Join our discord channel and ping me @justin.

Rainbros

  • Posts: 175
Well that's odd. Is there any reason it would lag for me in the player but not the browser?

Justin

  • *
  • Posts: 4007
Different player maybe? Flash (Player) is bundled by Stencyl, whereas Flash (Browser) is whatever version that chrome/firefox/safari/opera/whatever has installed as a plugin.

For Live Support: Join our discord channel and ping me @justin.

Rainbros

  • Posts: 175
Right, yeah. But it's a mystery as to why I'm seeing it and you're not...