Keep numbers on roulette wheel
finalcutbob
Member Posts: 130
Hi
I am making a game that uses a roulette wheel. When you push a button the wheel spins and then stops. My problem is putting the numbers on the wheel. I have an actor called number and I place an instance of the actor for each space on the wheel where I want a number but for the life of me I can't figure out how to keep the number in that space when the wheel turns.
Can anyone help me out with this ?
Thanks!
I am making a game that uses a roulette wheel. When you push a button the wheel spins and then stops. My problem is putting the numbers on the wheel. I have an actor called number and I place an instance of the actor for each space on the wheel where I want a number but for the life of me I can't figure out how to keep the number in that space when the wheel turns.
Can anyone help me out with this ?
Thanks!
Comments
Constrain X position to AAA*sin(self.time*BBB)+CCC
Constrain Y position to AAA*cos(self.time*BBB)+CCC
AAA = radius of roulette wheel.
BBB = speed of rotation
CCC = centre of wheel
For each actor you will need an offset so they are spread out around the wheel, this will look something like this:
Constrain X position to AAA*sin((self.time+DDD)*BBB)+CCC
DDD = offset in degrees.
(you'd need to check if the offset works, just made it up in my head, not near my computer right now, might check it myself later).
If you leave it where it is . . . Constrain X position to AAA*sin((self.time+DDD)*BBB)+CCC . . . then you'd need to divide degrees by 100.
So if you want a 180° offset use: Constrain X position to AAA*sin((self.time+1.8)*BBB)+CCC
And if you want a 90° offset use: Constrain X position to AAA*sin((self.time+0.9)*BBB)+CCC . . . etc etc.
Or you could move the offset ('DDD') outside the brackets like this:
Constrain X position to AAA*sin((self.time*BBB)+DDD)+CCC
. . . if you do it this way then you'd just enter the offset as normal degrees, so a 180° offset would be: Constrain X position to AAA*sin((self.time*BBB)+180)+CCC
I'll check this out in GS later, but pretty sure this works.
I made you a quick example file:
http://www.mediafire.com/?2f8p317e81rdx0d
P.S. I rotated the actors themselves to keep them aligned to their paths - I just used 'rotate' - take a look, it's pretty straightforward stuff.
38 slots, all being constrained by at least 3 three rules, X pos, Y, pos, rotation, then presumably some rules to detect collision with the ball, attribute changes . . . and so on.
That's an awful lot of CPU power being used, might be a bit much for an iPhone ?
It might be easier to construct the wheel with all your number slots and then simply rotate the camera - the effect will be identical but minus dozens of rules / constraints / attributes . . . ?
Any elements you want to remain static on screen - can sit on a layer with 'scrollable' switched off.
Great example RThurman. Thank you!
Thank you too Socks!
/bookmarked
Great! That means you will hit "new and noteworthy" one day faster.
When the appstore checks start rolling in -- we'll be waiting for our honorarium.
First, the easiest way would be to draw the new actor into the 'stationary' image. In the demo above, you would incorporate images of your non-moving actors in the the bezel image.
Second, the next easiest way would be to have large actors that have small images on them. Most of the actor's image would be background transparent. And the center of the actor needs to be placed in the center of the scene. (Just like the bezel actor is placed.) Then you rotate the actor the exact opposite speed as the camera. (Just like the bezel is being rotated in the demo.)
Third, if you want separate actors, then you need to go back to the method that @socks originally described -- that is you would need to use trig. to determine actors' position and rotation).