Actor can be moved by player's dragging on cell phone
HLQuan
Member, PRO Posts: 10
- I have create an actor named 'Player'.
- When playing it on Android cell phone,I can move this actor by dragging it.
- But there isn't a Drag Behavior in the CS (PC).
- How could I make it?
Comments
You mean you want to be able to drag it around? Try a rule like this:
Rule: If Touch is Pressed Constrain self.position.x to game.Touches.Touch1.x Constrain self.position.y to game.Touches.Touch1.y
Hope this helps.
But this is not a dragging. The actor will change its position suddenly.
In a game named 'Sky Force', I can drag my airplane in a certain linear velocity.
Another problem I've asked:
http://forums.gamesalad.com/discussion/75504/how-to-set-a-max-speed#latest
Are you sure you used the "Constrain Attribute" behavior and not "Change Attribute"?
And relating to your other post, if you wanted to make the actor follow the touch at a max speed, then Move To will stop functioning if the actor actually reaches the touch position. Instead, try this:
The first rule detects if somewhere was touched (if you only want to be able to drag the actor, change Inside and Outside to just Pressed). The inner rules (X and Y Allowance) make it so the actor doesn't jitter about when it reaches the touch... change each 4 to something lower for more accuracy. And finally the Move just moves it in the direction of the touch. The second picture is of the Direction for the Move.
There might be a better way of doing it, but this works for me. Good luck!