GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Expand touch field of actor

saad1993saad1993 Posts: 47Member, BASIC

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

  • jamie_cjamie_c ImagineLabs.rocks Posts: 5,528Member
    edited July 2016

    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.

  • saad1993saad1993 Posts: 47Member, BASIC

    @jamie_c said:
    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.

    I've tried that method, it makes the whole thing sort of jumpy. Are there any other, smoother methods you may know of?

  • ArmellineArmelline Posts: 4,717Member, PRO

    There are three ways to achieve this.

    1. 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.

    2. 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.

    3. Use logic. Example attached. Allows you to keep the same size actor, but is more work.

  • saad1993saad1993 Posts: 47Member, BASIC
    edited July 2016

    There are three ways to achieve this.

    1. 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.

    2. 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.

    3. Use logic. Example attached. Allows you to keep the same size actor, but is more work.

    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'.

  • ArmellineArmelline Posts: 4,717Member, PRO

    @saad1993 said:
    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.

    Then just go with the second option. The third option will work for that, but it'll be more work.

    Any ideas? BTW, the if statement in your rule to Actor 1 says 'Invalid path'.

    That's weird! Doesn't say that for me. Which bit exactly says that?

  • saad1993saad1993 Posts: 47Member, BASIC

    Then just go with the second option. The third option will work for that, but it'll be more work.

    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'.

    That's weird! Doesn't say that for me. Which bit exactly says that?

    Never mind, I figured it was 'if touch is pressed'.

  • saad1993saad1993 Posts: 47Member, BASIC

    That's weird! Doesn't say that for me. Which bit exactly says that?

    This is at the opening if statement for the Rule on Actor 1.

Sign In or Register to comment.