Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Timer Based Alpha

Author
Message
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 31st Oct 2011 13:41
I have sprites that I want to fade away.
I am using Alpha.

However I want them to fade away at a constant rate, if the game plays at 60fps or 30fps, etc...

I thought of using the same concept as time based movement. But somehow the results are strange and irregular.

Does anyone have any experience on the subject and can illuminate me?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 31st Oct 2011 15:53
I use something like this:


Set a time when it should no longer be visible then reduce the alpha based on the current time.

(untested code)

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 31st Oct 2011 20:06
I was using GetFrameTime() to increase Alpha values!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Nov 2011 10:45
That might be unreliable as you might get a compounding error. Using an end time that you track from the timer is more stable.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 1st Nov 2011 11:56
Even for X & Y movement, you think GetFrameTime() is unreliable?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Nov 2011 12:14
Just not as accurate.

I could be wrong but it seems like testing the difference between the last frame and the current one wouldn't be as accurate.

Logically it might be wrong as small floats are more accurate than large floats but maybe some testing would be a good idea?

I just prefer to measure increments from a fixed point rather than one at a time to avoid cumulative errors. In the real world it tends to be more accurate but I'm not 100% certain when it comes to this specific situation...

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 1st Nov 2011 16:30
I followed the simplest route and used GetFrameTime()

Fingers crossed I hope this works quite ok overall.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 1st Nov 2011 20:14
I checked these and GetFrameTime() was exactly the same as the whole ( LastFrame# - CurrentFrame# ) I use for my timer based mavement in all my apps, AppGameKit and DBP.

My signature is NOT a moderator plaything! Stop changing it!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 1st Nov 2011 21:52
Yes I made the same tests and printed the values, and the multiplier flats are the same.

Having a timer multiplier is good for X & Y movements, but for ANGLES and ALPHA I am doing something wrong as with 30fps the angle value is obviously bigger than with 60fps, so the sprite rotates more!

I need to find another solution!

Login to post a reply

Server time is: 2024-04-25 15:00:10
Your offset time is: 2024-04-25 15:00:10