I need some help making these touch controls. any ideas?

Hey Gamesalad users, I have looked and looked but haven't been able to find how to do this. there are tutorials for a touch joy stick. but what i am looking for is to be able to move an actor right, left, and up by touching anywhere on the screen and dragging you finger in the direction you want the actor to go. similar to the controls in the game Limbo by Play Dead. I need this specific control type for my game to work. any and all help is very much appreciated.

Comments

  • RossmanBrothersGamesRossmanBrothersGames Member Posts: 659
    edited May 2014

    You say that you can touch anywhere on the screen to do this so if you are only using one touch this can be pretty simple. Gamesalad can track the x,and y coordinates of a touch. I would make it so that the initial touch changes two attributes to store the initial x and y coordinates of the touch.
    Then have a rule that determines if the current x or y coordinate is greater or less than the initial. You may want to determine if it is greater by a certain amount so the game isnt too touchy.

    For example

    if touch.x is > initial.x+2 then change moveright to true (i would have boolean attributes trigger the movement).

    and also after the behavior is given to move the actor also change the initial x and y to the new coordinates so that it can determine further movement.

    another rule would be if touch.x is < initial.x-2 then change moveright false and moveleft true
    Make sure when the touch is release everything is set back to normal

  • SingleSparqSingleSparq Member Posts: 1,339

    Make an invisible actor. Ad rule if mouse button is down change attribute of actor x and y to mouse x and y (where your finger is). Have your hero actor then move towards that position. One thought always.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited May 2014

    Google swipe movement gamesalad. There are many explanations and videos related to this.

    [Merged two threads.] Please don't create multiple threads for the same issue.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RossmanBrothersGamesRossmanBrothersGames Member Posts: 659

    I don't think he is talking about swipe movements or movement where the actor moves toward the touch point, but rather something that is more like an invisible joystick that many games are using now and it works very well. Am I right @mathewvirgen ?

  • TosanuTosanu Member, PRO Posts: 388

    Well, the invisible joystick would require a True False statement based on if touch is pressed or not, which would then create an origin point where the touch is, and then adjust itself based on where the touch moves after that as long as it isnt released, correct?

  • RossmanBrothersGamesRossmanBrothersGames Member Posts: 659

    @tosanu yes that's how I would do it

  • aspiringgamemakeraspiringgamemaker Member Posts: 20

    Thanks everyone, @erockross especially. That is exactly what I am trying to do. I will try that pattern and give an update.

  • RossmanBrothersGamesRossmanBrothersGames Member Posts: 659
    edited May 2014

    @mathewvirgen‌ I ended up trying this out as I was planning on using it for a future game anyway. I ran into one problem in the method i gave you. The initial.x attribute would not reset the more you moved it left or right. This was because the position of your thumb while moving always stayed at a number greater than the previous x so the rule never reset.
    I found the best way to fix this was to use a timer the constantly resets the initial.x point to where your thumb is
    here is what I did:
    Made an actor covering the whole screen.

    Rule when touch is pressed:

           Timer every 0.2 seconds change attribute initial.x to mouse position x
    
           Rule if mouse position x is > initial.x + 2:
                               Change Game.MoveLeft to False
                               Change Game.MoveRight to True
    
           Rule if mouse position x is < initial.x - 2:
                               Change Game.MoveRight to False
                               Change Game.MoveLeft to True
    

    Otherwise:

    Change Game.MoveRight to False

    Change Game.MoveLeft to False

    Works perfect for left and right movement. If wanted the same logic could be applied to detect up and down movement.

  • aspiringgamemakeraspiringgamemaker Member Posts: 20

    Alright... I tried what you said @ecrockross and I can get it to work. What type of attribute did you use for the initial x?

  • aspiringgamemakeraspiringgamemaker Member Posts: 20
    edited May 2014

    I meant that I "can't " get it to work.
    I think it has something to do with the part when you said,
    " I would make it so that the initial touch changes two attributes to store the initial x and y coordinates of the touch."
    What is the best way to do that

  • aspiringgamemakeraspiringgamemaker Member Posts: 20

    Okay I tried adding a timer, every 0.2 seconds
    Constrain: game.initial x to: game.mouse position x
    And it works. So thanks for the help everyone.

Sign In or Register to comment.