How do I get touch controls to mimic keyboard input?

Get help using Construct 2

Post » Wed Feb 03, 2016 3:45 pm

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:

Image

Basically i want the same animation changes to occur for touch input as they do for keyboard.
B
7
S
2
Posts: 110
Reputation: 927

Post » Wed Feb 03, 2016 4:36 pm

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.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Wed Feb 03, 2016 5:47 pm

I dont understand what you mean..:(
B
7
S
2
Posts: 110
Reputation: 927

Post » Wed Feb 03, 2016 6:06 pm

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

Code: Select all
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
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Wed Feb 03, 2016 6:11 pm

7Soul wrote: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

Code: Select all
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


Sounds perfect, now i just need to figure out how to add that code.. :o
B
7
S
2
Posts: 110
Reputation: 927

Post » Wed Feb 03, 2016 8:02 pm

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?
B
7
S
2
Posts: 110
Reputation: 927

Post » Wed Feb 03, 2016 9:29 pm

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

Image

Player.Direction is an instance variable you should add to the player object (my bad, I forgot to mention that)
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Wed Feb 03, 2016 10:44 pm

Where is the "Or" condition? i can't find it..:(
B
7
S
2
Posts: 110
Reputation: 927

Post » Thu Feb 04, 2016 1:07 am

right click first event. in the menu (or)
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Thu Feb 04, 2016 10:01 am

Nevermind, found it.. :lol:
B
7
S
2
Posts: 110
Reputation: 927


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, kellehk, KSLR and 32 guests