How do I Fix this sprite mirroring issue?

Get help using Construct 2

Post » Sun Aug 30, 2015 10:26 am

I've experienced this problem while working on a personal project, but I recreated the problem In an example .capx. So I have a sprite that has the 8 direction behavior and it is set up so when I press the left arrow, it sets the sprite to mirrored and when I press the right arrow, it sets the sprite to not mirrored. Anyway, the problem is, when I hold left arrow and right arrow at the same time, it always sets itself to be mirrored no matter what order I press the keys in. I'll try to explain better what it's supposed to do, so if i'm holding down the right arrow to move right and I press the left arrow to stop the sprite it should stay un-mirrored, but if I do that it still sets it to be mirrored. Sorry if I'm hard to understand, it's like three am and I've been trying to fix this all night. I was hoping one of you knew how to help me with this, Thanks in advance :) https://www.dropbox.com/s/e3dvsd8eauafb ... .capx?dl=0

Edit: Fixed!
Last edited by Cam112549 on Sun Aug 30, 2015 7:31 pm, edited 1 time in total.
B
8
S
2
Posts: 39
Reputation: 604

Post » Sun Aug 30, 2015 1:51 pm

hi, can u please upload the file on sendspace, not on dropbox because there is a problem in downloading the file on dropbox
C2 Intermediate Developer
Feel free to contact me
B
7
S
2
Posts: 111
Reputation: 908

Post » Sun Aug 30, 2015 2:25 pm

@Cam112549 - yeah, dropbox seems to be having trouble right now.

Doesn't 8 direction already take care of mirroring? I don't think you have to manually do that...
There could be a number of things going on: if your code checks for the right arrow first, then the left arrow, then if both keys are down, the left arrow will be processed last, so your sprite will end up mirrored. So, checking left first may improve things - but then you would have the same issue going the other direction.

when your sprite is moving right, its 8direction.vectorX will be poitive. So you could set your sprite to mirrored only when both the left arrow is down and the 8direction.vectorX is negative. That way pressing left arrow to stop the motion wont make your sprite mirrored until it actually starts moving to the left.
B
94
S
33
G
20
Posts: 438
Reputation: 17,615

Post » Sun Aug 30, 2015 7:02 pm

yea @AllanR is right cuz the 8 directions behavior does the mirroring automatically and u can make the following if u dont want the sprite to be left or right, u can make this...
condition : 1.left arrow is down
2.right arrow is down
action : set animation to ur animation that is not pointing in any direction
... i hope u send a example for what is happening with u.
C2 Intermediate Developer
Feel free to contact me
B
7
S
2
Posts: 111
Reputation: 908

Post » Sun Aug 30, 2015 7:23 pm

@Ihab7 I recreated the bug again using the platform behavior, seeing as it doesn't mirror automatically, but it still does it. Here's the sendspace link: https://www.sendspace.com/file/tq6rgw

Edit: Fixed!
Last edited by Cam112549 on Sun Aug 30, 2015 7:31 pm, edited 2 times in total.
B
8
S
2
Posts: 39
Reputation: 604

Post » Sun Aug 30, 2015 7:31 pm

@AllanR I fixed it thanks to your help. I compared vectorx to see if it was positive or negative and it works! Thank you so much :)
B
8
S
2
Posts: 39
Reputation: 604

Post » Sun Aug 30, 2015 7:49 pm

yea, now i understand the bug correctly, i didnt understand it until u linked the project example :P
C2 Intermediate Developer
Feel free to contact me
B
7
S
2
Posts: 111
Reputation: 908

Post » Sun Aug 30, 2015 7:53 pm

and btw i didn't told u to make a platformer behavior man ! XD U just have to do it in the 8 directions behavior
C2 Intermediate Developer
Feel free to contact me
B
7
S
2
Posts: 111
Reputation: 908


Return to How do I....?

Who is online

Users browsing this forum: FlyingRam, jkmalau, marcinkowski and 10 guests