Originally Posted by
hwnd
Ok, but is it possible to take some constant and use the nxPascal "tick" to generate different animations with different framerate?
Slower / faster.
In my case, every block could have tile animation with his own frame rate. Some anims need slower FR, some bigger FR and still be same on any PC?
I mean animation that has slower framerate, will be actually faster in my friends computer, who has more faster pc.
This is demonstrated in the nxPascal demos many times. You have:
- nx.GetTick <= Returns multiplatform GetTickCount. It is a millisecond timer running onwards, each 1000 being 1 second.
- nx.GetTick2(range: integer; scale: single) <= Same as above, but you can limit it to certain range and scale
- nx.FrameTick <= FPS counter called GetTick in the Flip and stored it here. You don't need to ask it from system so it could be marginally faster, but this is 1 frame late.
What i prefer to use is the GetTick2(). For example:
Code:
nx.SetColor(1, 0, 0, 0.8+0.2*sin(toRad*nx.GetTick2(360, 0.5)));
It makes a red color with alpha being in range 0.6..1.0, smoothly going by sine-wave. With range 360 it always returns value from 0.0 .. 359.5. You can use different ranges and speeds for each animation. If you want it to loop animation patterns from end to start way, you can use modulus math:
Code:
trunc(nx.GetTick2(4, 0.001)) mod 4
This would return values from 0..3, like 0,1,2,3,0,1,... And being so slow that it only changes once per second.
(actually this is going so theoretic i might have to test to verify It's how it's supposed to work though.)
edit: Verified, returns single though.
But naturally you can animate your stuff with like:
Code:
AnimPos:=AnimPos+AnimSpeed; // Where AnimSpeed is any floating point number
With the default fixed FPS, it works same speed on every computer.
Bookmarks