Make an actor follow a part of an image

kiwacikiwaci Member, PRO Posts: 72
edited June 2014 in Working with GS (Mac)

hello,

i added an image to my game, and i want to make an actor track a part of that image. Note that the image is just spinning.

Thanks

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Track a part of that image...? So let's say you have a pinwheel or Wheel of Fortune disc with different colored sections. You then want an actor to follow a single color while moving towards it? Or to point towards it or...? And is the image/wheel/disc moving across the screen at all or just spinning in place?

    As you can tell, we really need more information here and maybe a sketch or screenshot too.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • kiwacikiwaci Member, PRO Posts: 72

    yes, it's something like the Wheel of Fortune disc with different colors sections, and it's spinning in place. The user will touch different color each time.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Okay... that answers one of my questions. What about the rest?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • kiwacikiwaci Member, PRO Posts: 72

    ya, i didn't notice it. I want the actor to follow a single color.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @kiwaci said:
    ya, i didn't notice it. I want the actor to follow a single color.

    I still don't know what you mean by that. You want the actor to move towards the current position of the color? And do you mean the edge of the circle where that color is or the center of the section? Or are you meaning that you want the actor to move in a circle just beyond the radius of the wheel but always next to a particular color... like the ball on a roulette wheel after it's found its spot?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited June 2014

    Perhaps an old thread on spinning actors will be of use?

    http://forums.gamesalad.com/discussion/52301/keep-numbers-on-roulette-wheel

  • kiwacikiwaci Member, PRO Posts: 72

    ok, i'll try to make it simple :D . i have actor1 witch is a circle like this http://goo.gl/eoYAv3, i only gave him a rotation behaviour , so it will only spin in his place. Then i have actor2 witch will track a color for example the red color ( in the image ), so when actor1 spins the red color change his place and actor2 tracks him. So when i ask the user to press the red color he will press actor2. I hope i was clear enough.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    So you just want each section/color of the wheel to be a separate actor that can be pressed? "Tracking" or "following" an actor makes me think that you want it to follow the color after a delay or at a distance. I think you mean that you want an actor constrained to the position of the color and the same shape and size as the color section.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited June 2014

    I would probably use math to check the position of the touch rather than using separate actors for each color. But that's over my head! =P

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • kiwacikiwaci Member, PRO Posts: 72
    edited June 2014

    @RThurman i downloaded the project you put on that thread, but i want to make it portrait .

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    @kiwaci said:
    ok, i'll try to make it simple :D . i have actor1 witch is a circle like this http://goo.gl/eoYAv3, i only gave him a rotation behaviour , so it will only spin in his place. Then i have actor2 witch will track a color for example the red color ( in the image ), so when actor1 spins the red color change his place and actor2 tracks him. So when i ask the user to press the red color he will press actor2. I hope i was clear enough.

    Your question is a little confusing, do you simply want to be able to detect if someone has pressed the red colour ?

    If that is the case then you don't really need a second actor to track it - as the area of the red section can be described mathematically - and if it can be described mathematically then you can know when the mouse is in that area . . . .

    I'm going to do some maths . . . I will be back in a minute . . . .

  • kiwacikiwaci Member, PRO Posts: 72

    @Socks said:
    yes, that what i'm trying to do

  • SocksSocks London, UK.Member Posts: 12,822

    If . . . .

    (vectorToAngle( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )- self.Rotation )%360 . . . . is larger than 75

    . . . and . . .

    (vectorToAngle( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )- self.Rotation )%360 . . . . is smaller than 105

    . . . and . . .

    magnitude( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y ) . . . . is larger than 75

    . . . and . . .

    magnitude( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y ) . . . . is smaller than 150

    . . . . then your mouse is over the red section.

  • kiwacikiwaci Member, PRO Posts: 72

    @Socks said:
    If . . . .

    (vectorToAngle( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )- self.Rotation )%360 . . . . is larger than 75

    . . . and . . .

    (vectorToAngle( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )- self.Rotation )%360 . . . . is smaller than 105

    . . . and . . .

    magnitude( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y ) . . . . is larger than 75

    . . . and . . .

    magnitude( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y ) . . . . is smaller than 150

    . . . . then your mouse is over the red section.

    is this going in the "tracker" actor's behaviour

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    @kiwaci said:
    is this going in the "tracker" actor's behaviour

    Serious question, is English your first language ? I don't mean to sound rude (that's not my intention!), but it's easy to assume someone is English when online when they might not be ?

  • SocksSocks London, UK.Member Posts: 12,822

    Here's a demo project:

    https://www.mediafire.com/?adbvip9mb3b9pvt

    Click in the red area.

  • kiwacikiwaci Member, PRO Posts: 72

    @Socks said:
    Serious question, is English your first language ? I don't mean to sound rude (that's not my intention!), but it's easy to assume someone is English when online when they might not be ?

    No, it's not but i do my best :D

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Here is another thread that uses math to determine which area the spinner stops on:

    http://forums.gamesalad.com/discussion/51306/wheel-of-fortune-how-would-you-do-it

  • kiwacikiwaci Member, PRO Posts: 72

    @Socks said:
    Here's a demo project:

    https://www.mediafire.com/?adbvip9mb3b9pvt

    Click in the red area.

    Thanks a lot.

  • SocksSocks London, UK.Member Posts: 12,822

    @kiwaci said:
    No, it's not but i do my best

    I suspected so :) but it's so hard to tell online.

  • SocksSocks London, UK.Member Posts: 12,822

    @kiwaci said:
    Thanks a lot.

    Adjust the numbers (is larger than 75 - and - is smaller than 105) to detect other colours.

  • kiwacikiwaci Member, PRO Posts: 72

    @Socks said:
    Adjust the numbers (is larger than 75 - and - is smaller than 105) to detect other colours.

    Ok

Sign In or Register to comment.