# Flip coin animation

Member Posts: 873
edited May 2012
hi,

I'm trying to create an animation of a coin that flip continuously but i have no idea how to do that. I'm using illustrator and this is my coin. any help is appreciated!

http://img155.imageshack.us/img155/1638/coinq.png

• Posts: 2,878
Out of my head because I am on my iPhone.

You could use this illustration without the shadow as an actor.

Then in the actor ad the following.

Constrain self.size.height to (1+(sin(self.time%360*z)/2))*64

z is a value that you can change to speed it up. So it can be any number depending on the speed you want. A higher number speeds up the rotation.

In this case 64 is the height/width of your coin. If your height/width is 32px then use 32 for example.

I hope there is no error in this. Otherwise let me know. (use my name with @ so I get a notice in your reply.
• Posts: 647
@LudwigHeijden

Would you mind explaining that formula for me? Looks like a great effect, but how the heck did you come up with that?

Thanks,
Jack McGraw
• Posts: 1,770
@patapple email me on creativeweb25@gmail.com with details.
• Posts: 2,878
Yeah, I was on my iPhone so had to do it out of my had which isn't recommended at my age
Here is a new formula, this one should work.

(1+sin( self.Time %360*700))*32

700 is the speed and 32 the height.

Here is an example project:
http://dl.dropbox.com/u/21686348/flippingCoin.gameproj.zip

• Member Posts: 873
@LudwigHeijden it doesn't work with your constrain attribute
• Member Posts: 873
I change the height to the width because I need a vertical flip. Now there is a problem:
the coin doesn't collide with the main character and I don't know why!

thanks a lot
• Member Posts: 2,878
Do you have a collide behavior or a rule that says.
It might not work when using a rule because GS thinks the coin doesn't have any height. -sigh-

In that case animating is a better option.
I made a flippping disk animation a while back:
http://dl.dropbox.com/u/21686348/coinflip.zip

You may use this free. A credit in your game would be nice

Good luck!
• Member Posts: 873
OK! thanks! do you have the psd file? so it easier for me to edit.

For sure a credit in my game will be to all the forum! ahahah
• Member Posts: 2,878
I don't have a .psd but you can open these in Photoshop...
• Member Posts: 2,878
@jckmcgraw
I forgot to explain the formula.
Its pretty easy. I don't know if you know anything about trigonometry but here is an explanation on that: http://en.wikipedia.org/wiki/Sine

It's not so complicated. But I am not good at explaining. Perhaps someone else can??
• Member Posts: 647
@ludwigheijden

I just learned basic trigonometry this year (8th grade geometry), and we haven't applied it to many situations.

Thanks for the help though!
Jack McGraw
• Member Posts: 2,878
You are lucky. Trigonometry has a purpose for you. To me it was al abracadabra. I really didn't know what use it ever could have.