Drag an actor by touch anywhere on the scene?

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

  • SocksSocks London, UK.Member Posts: 12,822

    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'

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

  • TitanFuryTitanFury Member Posts: 55
    edited May 2015

    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?

  • SocksSocks London, UK.Member Posts: 12,822

    @TitanHimself said:
    Thanks for the help Socks. I tried to do what you suggested but my problem still stands

    Can you take a screenshot of your rules ?

  • TitanFuryTitanFury Member Posts: 55
    edited May 2015

    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/

  • SocksSocks London, UK.Member Posts: 12,822

    @TitanHimself said:
    Yes, here are my original rules (the ones I started out with). The rules you gave me achieve the same result as these.

    The rules I suggested are not the same at the rules in the screenshot you provided, did you try the rules I suggested ?

  • TitanFuryTitanFury Member Posts: 55

    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.

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @TitanHimself said:
    Yes I did

    Your rules are not the same as the rules I suggested.

  • TitanFuryTitanFury Member Posts: 55

    Oh man, im so silly :neutral: I accidentally put "when actor is pressed" rather than "when mouse is down" (force of habit :s ). Thank you for your patience and help Socks, you da man!

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @TitanHimself said:
    force of habit :s

    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 ! :smile:

Sign In or Register to comment.