drag and constrain actor to specific position on screen

cmw333cmw333 Member Posts: 76
edited November -1 in Working with GS (Mac)
I have been working on a jigsaw drag and drop style puzzle very much like a free app on the app store called "shape puzzle HD Free". With the help of T-shirtbooth I was able to resolve the issue of actors sticking together when another actor collided. My only issue now is I have invisible pieces in place and when an actor collides with with wrong piece I set it so it would go back to the start position. The issue as far as I can see is that the invisible actors are too close together. Is there a way to use "magnitude(x,y) to constrain one actor to a specific place on the screen when correct or send it back to the start position when it is the wrong piece. Hope this makes sense to someone out there. I can send you exactly what I have so far and you will understand the problem.

regards

Chris

Comments

  • cmw333cmw333 Member Posts: 76
    cmw333 said:
    I have been working on a jigsaw drag and drop style puzzle very much like a free app on the app store called "shape puzzle HD Free". With the help of T-shirtbooth I was able to resolve the issue of actors sticking together when another actor collided. My only issue now is I have invisible pieces in place and when an actor collides with with wrong piece I set it so it would go back to the start position. The issue as far as I can see is that the invisible actors are too close together. Is there a way to use "magnitude(x,y) to constrain one actor to a specific place on the screen when correct or send it back to the start position when it is the wrong piece. Hope this makes sense to someone out there. I can send you exactly what I have so far and you will understand the problem.

    The issue is only when the actors are butted up together and not when they are spaced out.

    regards

    Chris

  • cmw333cmw333 Member Posts: 76
    Please help someone
  • expired_012expired_012 Member Posts: 1,802
    Yes, there is a way.

    You can create a real self attribute named something like "HowFarAway"

    and then in the draggable piece actor put in:

    constrain: self.HowFarAway to magnitude(self.posX-(X coordinate of the position you want it to be constrained to when correct), self.posY-(Y coordinate of the position you want it to be constrained to when correct)

    then you can make a rule saying that when the attribute HowFarAway is less than a number, constrain self position X and Y to the "correct" positions . In the otherwise you can put when att.HowFarAway is greater than a number, constrain the X and Y positions to the starting position.
  • cmw333cmw333 Member Posts: 76
    Hi artonskyblue

    thanks alot for your help but unfortunately I can't get it to work. I followed your instructions but it does nothing. Can I sent you my file that I'm working on for you to have a look at for me.

    regards

    Chris
  • expired_012expired_012 Member Posts: 1,802
    Sure thing.

    Please send it at artonskyblue(at)gmail(dot)com
Sign In or Register to comment.