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 / Bounce animation

Author
Message
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 8th Feb 2012 17:33
Hi guys,

This function is from the UCF project

function Bounce(x as float)
result# = abs(sin(6.28*(x+1)*(x+1)) * (1-x))
endFunction result#

I'm attempting to produce a nice bounce animation, but I'm not clear how to go about using it to that effect.

Any ideas?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Feb 2012 19:42
I would guess that if you feed it a value from the timer() you would get a height value back?

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 8th Feb 2012 20:13
I haven't actually used the function yet and I'm on my iPad ATM so I'm taking an educated guess based on the graph scraggle provided.

I think the basic way you would use this is y = bounce(x).

The first problem you might have is that the bounce is upside down because on a computer screen 0,0 is at the top left and y increases down instead of up. So to fix this try negating the function and then adding the screen height to the y value. So try this:

Y = getvirtualheight() - bounce(x)

These next ideas are educated guesses. Now, if you want to manipulate the function, to make the bounce higher/lower then multiply the bounce function by a value. If you'd like to make the bounce 'wider' try dividing everything in the sin function by a value.

I'll try these out later when I eventually get to me computer.

Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 8th Feb 2012 23:11
Thanks the timer() command did work, and from that I managed to work out the effect I wanted.

This media free program demonstrates how to make a sprite bounce from high to low. This basically means you need to set a value then subtract from it, or if you want it to bounce higher and faster rather than lower, then simply increase the value.

I've placed the variables at the beginning of the program so you can adjust these until you get the result you want.



I think this program more or less gives a classic bounce. With a little more work I'm sure you can make it produce the effect you need.

Login to post a reply

Server time is: 2024-11-23 01:04:22
Your offset time is: 2024-11-23 01:04:22