Expand touch field of actor
saad1993
Member, BASIC Posts: 47
Hello, I need to figure out how to expand the touch field on an actor so that when I touch let's say an area within a 60 pixel radius of the actor, I can grab it and move it around.
By default, the touch input has to be made right on the actor for the touch to work. That is very difficult to pull off. So basically, I want to make it easier to grab the actor and drag it.
Thanks!
Comments
One way would be to create your actor as a 60 pixel x 60 pixel actor and then use whatever image you want (assuming it's smaller than 60 pixels). AND in the Graphics settings of the actor choose the Fixed option for Horizontal and Vertical Wrap.
This will make the touch area of your actor 60 pixels square but the image will remain small within that area.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
I've tried that method, it makes the whole thing sort of jumpy. Are there any other, smoother methods you may know of?
There are three ways to achieve this.
Use a larger image than you need, adding transparent space around your actual image. This is super easy, but will mess up collisions if your actor needs collisions. If your image is 100x100px, make it 160x160px with the additional space being empty.
Use a custom collision shape. This is the same principle as above, but allows you to preserve collisions. Use a larger image with blank space, but add a custom collision shape for the size of the actual image.
Use logic. Example attached. Allows you to keep the same size actor, but is more work.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
The third option works fine for dragging. However, I need the object to be grabbed and released towards a certain point. This way it will have a set speed after release and direction will be essentially where the swipe points it to go.
Any ideas? BTW, the if statement in your rule to Actor 1 says 'Invalid path'.
Then just go with the second option. The third option will work for that, but it'll be more work.
That's weird! Doesn't say that for me. Which bit exactly says that?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
If at all possible, could you explain how to get it done with the third option? I believe it will be a lot smoother with logic. I think it would involve creating a new rule for 'when touch is released'.
Never mind, I figured it was 'if touch is pressed'.
This is at the opening if statement for the Rule on Actor 1.