touch constraint movement issue

jsorr2jsorr2 Member Posts: 279
edited November 2014 in Working with GS (Mac)

I have an actor constrained to x/y if touch is inside.
I want it to only be able to move in a 500width/500height box that is in the middle of the screen.

My code= "constrain self.X/Y to touch if x>=250, y>=250 x<=750, Y<=750 and touch is inside actor"
BUT as soon as it hits 250 or 750 (edge of box) the actor becomes stuck and can't be moved anymore.

How can I stop it from going outside the box, but still move it?

(I tried searching forums, but no luck)

Best Answer

  • SocksSocks London, UK.Posts: 12,822
    edited November 2014 Accepted Answer

    @jsorr2 said:

    When touch is pressed:

    Constrain X to max(250,min(750, game.Mouse.Position.X ))

    Constrain Y to max(250,min(750, game.Mouse.Position.Y ))

Answers

Sign In or Register to comment.