Mirror Sprite Based on dx?

Get help using Construct 2

Post » Wed Feb 27, 2013 7:43 pm

Hi!

I am brand new to Construct2, and am having a hard time wrapping my head around how to correctly access instance variables (perhaps this is the wrong word).

I have an done everything as suggested in the 2d platformer tutorial, and it works, after a fashion, but it doesn't suit my needs.

When changing direction, I want to set the Mirrored flag based on velocity. I hear this is dx. That makes sense. I cannot find how to check this variable. In a perfect world there would be a transition from running right->changing direction/slowing down->running left and vice versa based on dx (and other things like IsOnFloor or what have you).

So how do I do this? I've figured out how to check to see if something ELSE is >= to dx, but not if dx is <= 0. Please tell me I don't have to make a 0 CONST and check my CONST to see if IT is greater than dx.

I need it spelled out.

--Frustrated, and graciously awaiting your help.
B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Wed Feb 27, 2013 7:56 pm

Perhaps if the player is moving left but holding right, you would have a skidding animation?
Is this what you mean?

I'm not sure about velocity but if your character has a lot if momentum, you could just check if you are holding left when moving right and vice-versa.
B
11
S
2
G
3
Posts: 22
Reputation: 2,595

Post » Wed Feb 27, 2013 7:59 pm

yes, but my very newbie question is how do I check to see in which direction the character is moving?
B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Thu Feb 28, 2013 4:11 am

dx is called VectorX in the platform object. The expression you need is:

Sprite.Platform.VectorX

'Sprite' refers to the name of object with the platform behaviour. Then 'Platform' refers to the behaviour and 'VectorX' to the change in X direction. Also, you can always take a look at the platform behaviour in the manual.Nimtrix2013-02-28 04:14:13
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Thu Feb 28, 2013 4:05 pm

Thanks for the reply!

Believe me, I have scoured the manual in regards to expressions, platform, and the like. What I need is the understand of HOW to access that. How do I do what you just said?

What I am trying to do is click a button to add an event/condition that checks the Player.VectorX to see if it is below, at or above zero.

It seems to give me no option to do this.

I say this because if I create a condition to check some random thing I can THEN see the expressions pane and choose to see if something ELSE (That random thing I selected) is set to Player.VectorX, but I cannot access this pane when selecting the first part of a conditional check.

(Platform has things like CompareSpeed exposed! SPEED, but I need a velocity for my purposes. I even hear that VectorX and VectorY are Accompanied by Angle and Speed for Polar use, but I cannot find Angle either...)

This is why I am worrying about having to make a global const for ZERO and then checking to see if IT is greater than, equal to or less than Player.VectorX.

To me that seems like such a horrible and backwards way to access this information, and I don't want to stray too far from best practices before my character can even turn around fluidly, but it is as of yet the only way I can figure out how.

I thank you in advance!
B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Thu Feb 28, 2013 4:55 pm

Pretty easy if I am understanding correctly, create a new event:

System > Compare Two Values

For the First Value type ObjectName.Platform.VectorX

For the Second Value Type 0

And choose the comparison in the middle dropdown (Greater Than, etc...)

To make this easier, notice that when you are clicking in the text box for the first value, that there is a semi transparent window above the current one, mouse over it and you will get access to all the objects and their expressions...BluePhaze2013-02-28 16:56:49
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Thu Feb 28, 2013 5:24 pm

DING! Thank you so much!

I come from a more object-oriented background where things are very encapsulated, so it never occurred to me to check in System to compare a value for the player object...

Shifting my thinking is proving difficult, so I will definitely be back with more poorly-worded, yet ultimately easy-to-answer, questions.
B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Thu Feb 28, 2013 6:33 pm

@cincipon YEah same here, my background is in .Net development, though way back in the day I did a lot of flash dev too...
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418


Return to How do I....?

Who is online

Users browsing this forum: Braus and 12 guests