Keep numbers on roulette wheel

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!

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    Can you not simply make up a roulette wheel image with the numbers already on ?
  • finalcutbobfinalcutbob Member Posts: 130
    No, I need to be able to change them.
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    If you need separate number actors - then move them in a circle using sin and cos.

    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).

  • finalcutbobfinalcutbob Member Posts: 130
    Awesome, Thanks Socks!
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    Just thought about this, it all works except how I placed the offset ('DDD'):

    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.
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    Yep, just checked, it all works fine.

    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.
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    Thinking about this some more . . . .

    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.
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    // DP
  • finalcutbobfinalcutbob Member Posts: 130
    Thanks Socks. I'm at work right now, but I'll look at it when I get off.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Gotta agree with @Socks on this one. It is much easier on the CPU to rotate the camera than use all those constrains. Here is an example that someone asked for a few weeks ago.

  • finalcutbobfinalcutbob Member Posts: 130
    Oh man what a difference. I definitely see what you're talking about.
    Great example RThurman. Thank you! :)
    Thank you too Socks!
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Glad its going to work for you!
  • DeadlySeriousMediaDeadlySeriousMedia ArizonaMember Posts: 838
    edited January 2013
    So glad I found this thread! An idea popped into my head yesterday and this completely builds the foundation for it! You guys saved me a major head ache and so much time!

    /bookmarked
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited January 2013
    @DeadlySeriousMedia

    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.
  • guillefaceguilleface Member Posts: 1,014
    @rthurmanhow do you make other actors stay in the same position, like i add a new actor but it rotates too.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    @guilleface -- well, there are three ways to that come to mind

    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).
  • guillefaceguilleface Member Posts: 1,014
    thanks rthurman, but i downloaded the zip file you post,and it seems the same as @socks said, i definitely looking for a method to add a third actor that is not affected by the camera but unchecking scrollable layer dont work,all i need is add 3 more actor , one will display a question depending the value of the wheel, and 2 more that i will use to click for yes or no.but i will try the other methods thank you for your help.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    @guilleface -- you can modify the demo so that the rotation only takes place the wheel needs to spin. Then stop the rotation and ask the question.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    @guilleface -- here is a quick demo that might work for you.

  • guillefaceguilleface Member Posts: 1,014
    thanks a lot RThurman really crazy rules for me lol, thats why when i add a new actor it always rotates, i had never used or understood vector to angle so i did not know how to implement this, hopefully i will learn some new things from this :)
  • SolarPepperStudiosSolarPepperStudios Member Posts: 754
    @Socks Wow, you must really love AAA*sin(self.time*BBB)+CCC... Your signature is right! :D
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Glad it will work for you!
Sign In or Register to comment.