Author Topic: How does flixel deal with timing?  (Read 2450 times)

Melly

  • Member
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
How does flixel deal with timing?
« on: Mon, Jun 8, 2009 »
I have seen some oddities related to differing framerate in browsers when playing aroudn with flixel, like with the particle 'shower' at the score screen in mode. in IE, where the framrate seems to cap at around 60, the particles last longer and fall to the bottom of the screen where in firefox, where the framerate is at around 90, they vanish around the middle.

It kinda seems some parts of flixel use a timer and others count frames. It's a bit confusing.

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
Re: How does flixel deal with timing?
« Reply #1 on: Mon, Jun 8, 2009 »
Nah, I just set the interval on that emitter to less than 1/100th of a second is all, silly of me!

Melly

  • Member
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: How does flixel deal with timing?
« Reply #2 on: Tue, Jun 9, 2009 »
And how does that create the inconsistency I mentioned?

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
Re: How does flixel deal with timing?
« Reply #3 on: Tue, Jun 9, 2009 »
If it is running at 60 fps and the delay is less than 1/100th, then if the framerate is 90 fps it will emit particles faster since as previously discussed the emtter currently only emits one particle per frame in continuous mode

prettymuchbryce

  • Guest
Re: How does flixel deal with timing?
« Reply #4 on: Thu, Jun 11, 2009 »
is there an easy way to set the framerate? Also is Update() called each frame?

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
Re: How does flixel deal with timing?
« Reply #5 on: Thu, Jun 11, 2009 »
This emitter problem was corrected in the new build.  You can set the framerate someplace in FlxGame but I just have it set to 90.  If it can't do 90 then it'll do less and the FlxG.elapsed variable will accomodate that.  Update() is called every frame

CosMind

  • Member
  • **
  • Posts: 6
  • Karma: +0/-0
  • stuff 'n stuff
    • View Profile
    • Glum Buster
Re: How does flixel deal with timing?
« Reply #6 on: Sat, Aug 21, 2010 »
this issue causes me some major issues, too.
not in the flixel libraries themselves, but when implementing my own timers.
so, how was this resolved directly in the libraries?  is it the way the if condition and while loop are implemented in this code?

Code: [Select]
//@desc Called automatically by the game loop, decides when to launch particles and when to "die"
override public function update():void
{
_timer += FlxG.elapsed;
if(delay < 0)
{
if(_timer > -delay) { kill(); return; }
if(_sprites[0].exists) return;
var sl:uint = _sprites.length;
for(var i:uint = 0; i < sl; i++) emit();
return;
}
while(_timer > delay)
{
_timer -= delay;
emit();
}
}

if that's the case, then i be :D -- this means i can simply rip off what you've done here to solve my woes.

edit
btw -- this issue doesn't only affect cross-browser play; it also rears its head when the flash player's native "zoom" feature is used, or when you change the render scale of the .swf in the flixel startup code.

edit edit
n'ermind!  that code i pasted has absolutely nothing to do with this functionality at all.  sorry 'bout that :-[
i do believe that i've finally figured out what my issue is, though.
« Last Edit: Sat, Aug 21, 2010 by CosMind »