frame rate behavior


[ Zettels Traum ] [ search / suche ]

von dp am 23.August 98 um 18:15:50:

Just sharing a little code here...

Here's a tiny little behavior which will tell you how
fast (frames-per-second) your movie is *really* running.

The behavior is useful for testing the speed of your
movies, since you want to be sure to use every ounce
of computing power you have...  ;-)

I've recently been doing some graphic intensive projects
with lots of sprites flying around the stage, and I use
this behavior to determine how many sprites I can have
going at once.  When the frame-rate drops below a certain
point, no more new sprites are added.

The behavior is currently set to report the frame-rate-
average over a sample of 30 frames.

Useage:
Drop this behavior on a field and it'll report the
current frame-rate (average) in that field.

Enjoy the code!
        -- Alex


-- Frame Rate Behavior

property samples, frms, sTick, avg

on beginSprite me
  -- Number of Frames to Sample
  set samples = 30

  reset( )
end

on enterFrame me
  -- Ticks Per Frame.
  set tpf = float(60.0 / the frameTempo)

  -- Percent and Average.
  set percent = ((frms * tpf)/(the ticks - sTick))
  set avg = the frameTempo * percent

  -- Report the Average.
  set spNum = the spritenum of me
  put avg into field (the member of sprite spNum)

  if frms < samples then
    set frms = frms + 1
  else
    reset( )
  end if
end

on reset me
  -- Reset Variables.
  set sTick = the ticks - 1
  set frms = 1
end

Alexander Palmö






















D. Plänitz