How do I make my character change color after damage?

Get help using Construct 2

Post » Sun May 04, 2014 8:53 pm

I was wondering if it was possible to have my sprite flash red and flicker when it is hit without drawing extra frames in another program. And if so how?
B
7
Posts: 10
Reputation: 373

Post » Sun May 04, 2014 9:15 pm

First, give the sprite the Tint effect, default settings make it red. Then, at the start of the layout, disable the effect.

Next, give the sprite the Flash behaviour.

Now create a function that you'll call whenever the player is damaged. In that function, set the tint active, then start the flash behaviour, then wait a period of time, then set the tint inactive.

I've attached a quick example of this in action.

Note that this uses a WebGL effect, so this won't work if there's no WebGL support on your target platform. If you want to be absolutely rock-solid, then you might have to create new sprites with the red tint already applied. Flash will work regardless, though.
You do not have the required permissions to view the files attached to this post.
B
57
S
15
G
11
Posts: 912
Reputation: 12,626

Post » Sun May 04, 2014 9:59 pm

GeometriX wrote:First, give the sprite the Tint effect, default settings make it red. Then, at the start of the layout, disable the effect.

Next, give the sprite the Flash behaviour.

Now create a function that you'll call whenever the player is damaged. In that function, set the tint active, then start the flash behaviour, then wait a period of time, then set the tint inactive.

I've attached a quick example of this in action.

Note that this uses a WebGL effect, so this won't work if there's no WebGL support on your target platform. If you want to be absolutely rock-solid, then you might have to create new sprites with the red tint already applied. Flash will work regardless, though.



Thank you so much this is exactly what I was looking for. I'm updating my Windows Phone 8 app so I wont be able to use the red right now but once 8.1 is released then webgl shouldn't be an issue. You should add this to the tutorials on this site.
B
7
Posts: 10
Reputation: 373


Return to How do I....?

Who is online

Users browsing this forum: kurtbal, Seruza and 7 guests