How do I Get platformer negative value on X?

Get help using Construct 2

Post » Mon Apr 10, 2017 7:32 am

Hi, i want set walking animations from the value of platform movement. But it is always positive value. If i move on -X a set it to Left and on positive X a want to set it to walk right. How to do this , because the platform value is always positive number. And i dont want to use pressed arrow keys and such. Thank you.
B
11
S
3
G
1
Posts: 419
Reputation: 1,782

Post » Tue Apr 11, 2017 8:48 am

Is there some reason you don't want to use triggers like "is pressing left" to set your animations? It sounds like you're trying to make it hard on yourself for no purpose.

X position is always going to be positive unless you have unbounded scrolling enabled... 0 is left side of the layout and it only counts up as you move to the right. This is how coordinates work. If you don't want to use the supported triggers for simple actions, then you will need to make some variables that check the position of the player every tick - then compare those values to see if the player moved left or moved right, and set your animations accordingly.

Honestly though, unless you have some unavoidable necessity to NOT use "is pressing left" (or right) then I would just use those triggers... that's why they're there.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Thu Apr 13, 2017 7:15 am

Hi thank you. I want to use values because i use many animations on my player. I have walking , walking shoting, shoting idle, running , running shoting , jumping , jumping shoting, crawl, and so on and it seems too complicated use arrows.
B
11
S
3
G
1
Posts: 419
Reputation: 1,782

Post » Thu Apr 13, 2017 8:15 am

The expression Sprite.Platform.VectorX returns a negative number when moving to the left, positive when moving to the right and zero when idle.

You can do the mirroring & the walk/idle animations under it, but only under the strict condition that you constrain the logic to catch the exceptions. And there are a lot exceptions.

When Sprite.Platform.VectorX is less then zero you want the mirroring to happen, but the 'walk' can not happen when in the air, and also not when there is an 'attack' playing.

The flow and the logic is not that easy. But in the end you will have to catch the 'attack' exception any way, and the 'crunch' and.......... etc.

.... and the 'is at wall' when using only the triggers to animate, you dont want it to walk when standing still for a wall.

So in the end, it will be a mix.
Using the triggers for the 'mirroring', for starting the 'jump' animation, for starting the 'fall' animation, for starting an 'attack' .... & Using the Sprite.Platform.VectorX to fall back on the 2 defaults, "walk' & idle after any of the others ended and there is not other exception in play.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Apr 15, 2017 11:26 am

ex32 wrote:Hi thank you. I want to use values because i use many animations on my player. I have walking , walking shoting, shoting idle, running , running shoting , jumping , jumping shoting, crawl, and so on and it seems too complicated use arrows.


Makes sense, but you can use the arrow keys to simply set a variable (instance or global, whatever suits) just to get a value for the direction. Use this in your comparison event as a flag/trigger for current direction.

It would however be easier, as suggested by others, to make a variable for curX and curY, and compare to another set of variables like oldX and oldY. This will tell you which direction you are moving and/or facing.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Sun Apr 16, 2017 6:39 pm

Thank you very much , All your answers , solved the problem.
B
11
S
3
G
1
Posts: 419
Reputation: 1,782


Return to How do I....?

Who is online

Users browsing this forum: Artcadev and 24 guests