How do I squash and stretch sprite correctly?

Get help using Construct 2

Post » Thu Jun 09, 2016 9:12 am

Hi,

Currently I'm trying to make player sprite to squash a bit on landed. I'm doing it with sine behaviours. There are total of 2 sines, WidthSine and HeightSine. "on landed" -event will activate both sines.

The problem: when player is not moving and lands on ground, sprite goes from mirrored to not mirrored when sine behaviour is activated. When player sprite is not mirrored everything works fine. Also, this problem only occurs when player is not moving.

I checked values in debug-mode and I found out that when sprite is mirrored it's width is negative value and when it's not mirrored same value is positive. Then, when sine behaviour is activated it will set sprite's width value to positive. Other words, that will set sprite not mirrored.

Is this a bug in sine behaviour? @Kyatric, @Yahn, @Ashley

If not, how I prevent sprite/sine from mirroring unintended way?

Here is an example: h*t*t*p*s://www.dropbox.com/s/5cn6hl1fiwc29rj/squash%20and%20stretch%20demo.capx?dl=0

-M-

EDIT:

I found out what is the problem. Apparently the problem is vectorX check. How I fixed it: I Made a global variable "Facing_Direction" and when VectorX is less than 0 -> set Facing_Direction to "left". If it's greater than 0 - > "right". Then I added events: Facing_Direction is "left" -> set sprite mirrored and vice versa.

Now, on landed will trigger both sine behaviours and they work like intended :)

Last thing I needed to add was to set correct size of the sprite object. I made that with function.

If anyone is interested to see the result, here it is: h*t*t*p*s://www.dropbox.com/s/hliduujttc7j9jn/squash%20and%20stretch%20demo2.capx?dl=0

-M-
Last edited by Mithrill on Thu Jun 09, 2016 1:05 pm, edited 1 time in total.
B
16
S
2
Posts: 58
Reputation: 980

Post » Thu Jun 09, 2016 12:56 pm

I fail to see a logical reason why this would happen with your events.
So likely it could be a bug with the sine behavior "unmirroring" sprites by default when modifying their width.

Consider posting a bug report following the bug report guidelines.
You can add this repro capx to your report as well if you want.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,317
Reputation: 87,483

Post » Thu Jun 09, 2016 1:11 pm

Thank you @Kyatric for you quick reply. I will post a bug report right away :) I also found a workaround how to fix that sine behaviour. Check my first post for details.

-M-
B
16
S
2
Posts: 58
Reputation: 980


Return to How do I....?

Who is online

Users browsing this forum: Mayfly and 8 guests