Make and actor move up or down Or Left and right

Can anyone point me in the direction of a tutorial that shows my students how to make an actor (in this case a surfer) move up and down by touching and dragging on the screen. In this instance the actor is off to the right hand side of the screen and the touch area is on the left. He doesn't want any buttons or arrows on the screen. I had a student ask something similar in a game where they wanted to drag a Moustache left and right but only touching below the screen. Ive seen some very good tutorials on actually dragging an object but this involves touching the actual actor and dragging it.

thanks

Comments

  • VolontaArtsVolontaArts Member Posts: 510
    do you want the swipe type or the holding your finger down and wherever your finger goes the surfer goes?
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited September 2013
    Have an invisible actor on the left of the screen, at least wide enough to touch, and full screen height if you want the actor to go up and down full screen.

    Add a game attribute called TouchY.

    On the invisible actor added above add a rule like this:

    If touch is inside
    Constrain Attribute: TouchY = game.Mouse.Position.Y

    On your surfer actor add this:

    Constrain Attribute: self.Position.Y = game.TouchY

    That will give you an up and down trackpad at the left of the screen.

    You can do a similar thing with a left and right trackpad at the bottom of the screen for moving a moustache, but with the Mouse.Position.X value

    Let me know if anything is incorrect above
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Here's an example of the vertical trackpad. I'm setting game.Y with the initial position of the orange actor because otherwise game.TrackY is 0 when it first starts and it places the orange actor at the bottom of the screen, that change attribute only works the first time the actor is loaded, after that it uses the constrain attribute below it.

Sign In or Register to comment.