Drag an actor by touch anywhere on the scene?
TitanFury
Member Posts: 55
Hey there!
I have an actor that is currently controlled by the user as they drag the actor across the scene. This was done with a dragging attribute and game.mouse.position.X/Y attributes. However, I wish to control the actor by touching and dragging anywhere on the scene. As of now, the dragging feature only works when I touch the actor itself. Any help in regards to this is greatly appreciated.
Hopefully this makes sense
Cheers,
Andrei
Comments
Make 2 real attributes for the actor - 'offset X' and 'offset Y'.
Rule: When mouse button is down:
Change 'offset X' to Mouse X - self Position X
Change 'offset Y' to Mouse Y - self Position Y
Constrain self Position X to Mouse X - 'offset X'
Constrain self Position Y to Mouse Y - 'offset Y'
Thanks for the help Socks. I tried to do what you suggested but my problem still stands
You see, want to be able to drag from OUTSIDE the actor and still make the actor move as I move my finger across the screen/scene. Right now, the actor only moves when I touch and drag the actor, but not when I touch and drag regions outside the actor.
Iv'e attached a picture to provide a better understanding. Any input on this?
Can you take a screenshot of your rules ?
Yes, here are my original rules (the ones I started out with). The rules you gave me achieve the same result as these.
Edit: there is an otherwise for the first rule that changes self.dragging to false.
http://postimg.org/image/f9tf0563j/
The rules I suggested are not the same at the rules in the screenshot you provided, did you try the rules I suggested ?
Yes I did
http://postimg.org/image/x8rw1lgfx/
But when I click on the background of the scene (not the actor) the actor doesn't move.
Your rules are not the same as the rules I suggested.
Oh man, im so silly I accidentally put "when actor is pressed" rather than "when mouse is down" (force of habit ). Thank you for your patience and help Socks, you da man!
Yeah, it's easy to fall into habits . . . to me all scenes are landscape iPad, even if someone insists they are working on a portrait iPhone project I will give them coordinates for a landscape iPad !