0 Favourites

How do I get touch controls to mimic keyboard input?

  • Hi,

    So i have a simple platform object with zero opacity and my character sprite pinned to it which changes animation depending on direction of travel. Everything works fine on keyboard controls, but not so much the touch controls.

    I have added left and right touch events using the "simulate control action" and the chracter does indeed move the desired direction, but none of the animations changes occur, i was hoping they would be inherited from the keyboard controls.

    maybe this screen explains better:

    Basically i want the same animation changes to occur for touch input as they do for keyboard.

  • one your using 8 way set to 4 way vs on touch using platform behavior.

    so you could add custom movement and add up and down. or set 8 way vs platform.

  • I dont understand what you mean..

  • Instead of using the keyboard to tell which animation to play, make it so the movement of the object sets the animation. This way either input method will result in the same group of events

    PlayerSprite Platform Vector X > 0
        Set animation "Walk Right"
    
    PlayerSprite Platform Vector X < 0
        Set animation "Walk Left"
    
    PlayerSprite Platform Vector X = 0
    +Player.Direction = 1
        Set animation "Idle"
    Else
        Set animation "Idle Left"
    
    Keyboard Right is down
    OR
    Is touching TouchRight
        Simulate Move left
        Set direction to 1 
    
    Keyboard Left is down
    OR
    Is touching TouchLeft
        Simulate Move left
        Set direction to -1 
    [/code:3qecvlrq]
  • Instead of using the keyboard to tell which animation to play, make it so the movement of the object sets the animation. This way either input method will result in the same group of events

    > PlayerSprite Platform Vector X > 0
        Set animation "Walk Right"
    
    PlayerSprite Platform Vector X < 0
        Set animation "Walk Left"
    
    PlayerSprite Platform Vector X = 0
    +Player.Direction = 1
        Set animation "Idle"
    Else
        Set animation "Idle Left"
    
    Keyboard Right is down
    OR
    Is touching TouchRight
        Simulate Move left
        Set direction to 1 
    
    Keyboard Left is down
    OR
    Is touching TouchLeft
        Simulate Move left
        Set direction to -1 
    [/code:68c7kf24]
    

    Sounds perfect, now i just need to figure out how to add that code..

  • I can't figure this out, how is it supposed to look in an event sheet, anyone got an example Capx i can take a look at please?

  • To access Player.Platform.VectorX you use the system event "compare two values", as such:

    Player.Direction is an instance variable you should add to the player object (my bad, I forgot to mention that)

  • Where is the "Or" condition? i can't find it..

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • right click first event. in the menu (or)

  • Nevermind, found it..

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)