Re: Timing issue
- From: "Daniel" <DanielV@xxxxxxxxxxxxxxxx>
- Date: Wed, 9 Aug 2006 09:05:31 +0100
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.
.
- References:
- Timing issue
- From: Daniel
- Re: Timing issue
- From: Robert Dunlop [MS MVP]
- Timing issue
- Prev by Date: Re: Timing issue
- Next by Date: Re: .x Models + animations.
- Previous by thread: Re: Timing issue
- Next by thread: VB.NET Managed DirectX, After Call Video.RenderToTexture, video object can't accessed anymore.
- Index(es):
Relevant Pages
|