drag and constrain actor to specific position on screen
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
regards
Chris
Comments
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.
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
Please send it at artonskyblue(at)gmail(dot)com