How do I

Get help using Construct 2

Post » Thu Jun 15, 2017 3:31 pm

I have a sprite with 3 animation frames. Iwant them to respond to the x axis of a controller as it is moves to the right. So when the value is between 1-20 it is on frame 1, 20-40 frame 2, 40-60 frame the ext...

I put two conditions setting a minimum and maximum x analog number but I can't get it to work.
B
5
Posts: 4
Reputation: 233

Post » Thu Jun 15, 2017 4:00 pm

Hi,
I don't know your project but there always several solutions.

You could create 3 invisible sprites and say that when your player is overlapping a specific one of those then you play whichever frame you want.
Thank you to Construct 2 for giving me the ability to create games without programming knowledge.
My games & gaming portal = DolyGames
If anyone wants to cooperate to help each other Win-Win please email me - I am always happy to discover new opportunities.
Cheers,
COSMOS
B
21
S
10
G
1
Posts: 83
Reputation: 2,293

Post » Thu Jun 15, 2017 4:42 pm

When it is in steps of 20 ...
And you have 3 frames (zero index)
Then ... AnimationFrame = Max ( floor(value/20) , 2 )

When you want to spread a range over 3 frames ....

AMax = Maximum allowed analogue number.
AMin = Minimum analogue number.
ACur = analogue number at this moment.

AMax - AMin = Range .. Now lets normalise those with as rule that Amax should return the value 2 (zero based)

Ratio = 3 / Range
Norm = Ratio * Acur
Norm = (3/Range) * (ACur)
Norm = (3/ (AMax - AMin) ) * (ACur)
This returns numbers with decimals, animation frame will not take numbers with decimals, so we have to round that number.
So
AnimationFrame = Floor(Norm)

AnimationFrame = Floor((3/ (AMax - AMin) ) * (ACur))
Last edited by 99Instances2Go on Thu Jun 15, 2017 5:15 pm, edited 1 time in total.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Jun 15, 2017 5:00 pm

How do i input ACur? I cant find a way to put the analogue value in the equation.
B
5
Posts: 4
Reputation: 233

Post » Thu Jun 15, 2017 5:18 pm

ACur = analogue number at this moment / x axis of a controller at this moment

I assume that you know how to read the controller.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo and 32 guests