moving actor

how do i make it when i touch the left side of the screen the actor goes left and when i touch the right side the actor goes right.

Comments

  • IceboxIcebox Member Posts: 1,485

    Here is one way to do it, (there are other ways)

    in your actor
    if mouse button is down , and game.mouse.position.x is > game.screen.size.width/2
    Move direction 0(right) and speed value

    if mouse button is down , and game.mouse.position.x is < game.screen.size.width/2
    Move direction 180(left) and speed value

    if you dont want to use move you can use change attribute , change velocity , constrain attribute , move , what ever you want :)

  • chelgesonchelgeson Member Posts: 17

    thanks!

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited May 2016

    @chelgeson have you thought about what will happen if the character is at the far left of the screen and they press on the left side of the screen but at the right side of the character? Would you not want the character to move right? I think being a player I'd expect it to move right not further left.

  • chelgesonchelgeson Member Posts: 17

    very true, how would i program it to do that then?

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

    @chelgeson said:
    very true, how would i program it to do that then?

    When mouse button is down
    --When mouse X is larger than self X
    ----Move Right
    --Otherwise:
    ----Move Left

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

  • IceboxIcebox Member Posts: 1,485
    edited May 2016

    Deleted this post , thought it was something else

Sign In or Register to comment.