Re: Timing issue

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi Robert,

Wanted to reply to let you know that the last method you mentioned was the
one! :) I see why it was confusing, you see the original advice from ZMan
was to solve a flashing effect i wanted. I was then using that forumla to
control the speed of animation of another object. So yes two different ways
of using the same implementation.

The final method you gave worked perfectly. I can give it any seconds i like
now, even 0.01 of a second works setting x to 0.01f.

Thank you for your help and patience and for sticking with it. This has been
a huge help and something can use in every animation of my project, you're a
star!

Hopefully other people stuck on the same issue will gain from this as well.

D


"Robert Dunlop [MS MVP]" <rdunlop@xxxxxxxx> wrote in message
news:OKFL6BzuGHA.2036@xxxxxxxxxxxxxxxxxxxxxxx
"Daniel" <DanielV@xxxxxxxxxxxxxxxx> wrote in message
news:uF0866huGHA.4952@xxxxxxxxxxxxxxxxxxxxxxx
Hey guys

I was advised that the best animation method is to update the animation
on a time basis rather than frame basis, which i agree with so that even
on varying procesor speds the animation will remain consistent.

ZMan pointed me to this formula:

if( _gameTime.Seconds/x % 2 > 0 )
//then next frame

The idea being that you set x to however many seconds you want your next
frame to kick in on. So ever second set it to 1, every 2 seconds set it
to 2 etc.

However Z said that this will also work for half seconds but i am finding
it doesnt? How can i use a similar equation so that i can move to my next
frame in the animation every 0.5 seconds?

Reading back through this, I think I may understand what you are looking
for. Try this:

// declare this at a level where it won't go out of scope between tests
int lastFrame=0;

// frame test
int thisFrame=(int)(_gameTime.TotalSeconds/x);
if (thisFrame!=lastFrame) {
lastFrame=thisFrame;
// handle next frame
...
}


--
Robert Dunlop
Microsoft DirectX MVP
http://rdunlop.spaces.msn.com/
-------------
The X-Zone
http://www.directxzone.com/
-------------
The opinions expressed in this message are my own personal views and do
not reflect the official views of the Microsoft Corporation.
The MVP program does not constitute employment or contractual obligation
with Microsoft.



.



Relevant Pages

  • Re: Fade into a Picture Box or Image Control
    ... Joe users old P3 only manages to draw a couple of frames a second and the same animation takes forever. ... Dim StartTime As Long, EndTime As Long, TimeNow As Long ... Where DrawFrame() draw the frame at the given opacity, I prefer doing this rather than cluttering the animation loop ...
    (microsoft.public.vb.winapi.graphics)
  • Re: Sagnac Threads United
    ... I've made minor internal changes to my animation. ... My animation is NOW for a large rotating ring. ... nature of those 'apparent' motions in YOUR ROTATING frame. ...
    (sci.physics.relativity)
  • Re: How do I generate an animated pdf file from xfig/metapost
    ... I will post the source code below for an animation that ... I've done which illustrates how an ellipse is constructed. ... This PDF will have each frame of the ... Draw the ellipse dashed ...
    (comp.text.tex)
  • Re: Flashing a sprite
    ... you've reached the end of the animation, in which case frameIndex would go ... I guess the 2 would be my amount of seconds....but after gametime ... frames display frame 0, x amount of frames display frame 1" etc... ... you could just make a 2-frame animation for your flashing sprite. ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: Timing issue
    ... I was advised that the best animation method is to update the animation on a time basis rather than frame basis, which i agree with so that even on varying procesor speds the animation will remain consistent. ... The opinions expressed in this message are my own personal views and do not reflect the official views of the Microsoft Corporation. ...
    (microsoft.public.win32.programmer.directx.managed)