How do I blink a sprite when the player gets hit?

Get help using Construct 2

Post » Wed Jun 18, 2014 7:01 pm

How do I make the player sprite blink/flash when it gets hit by a bullet?

for instance:

if (the player gets hit by a bullet){
the player flashes with a solid white color}

thanks!
B
3
Posts: 6
Reputation: 187

Post » Wed Jun 18, 2014 7:57 pm

there is a build in behavior called flash.
Give it to your sprite and just add this
Bullet on collision with sprite--------. sprite flash
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Wed Jun 18, 2014 9:16 pm

Roccinio wrote:there is a build in behavior called flash.
Give it to your sprite and just add this
Bullet on collision with sprite--------. sprite flash


Ive already tried the flash behavior but it just turns the sprite invisible.
Is there a way to make the sprite glow instead?

thanks!
B
3
Posts: 6
Reputation: 187

Post » Wed Jun 18, 2014 9:21 pm

It makes your player invisible because it runs every tick and the flash behavior resets all the time. add a trigger once in your command to stop this from happening.
you must understand how conditions work in programing.if something is true it will run 60times a second unless you tell it to do it only once when the condition triggers for the first time.
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Wed Jun 18, 2014 9:25 pm

If you don't mind relying on WebGL effects, you could have the following:

Code: Select all
If [Bullet] overlaps [Player]
~~~then~~~
Destroy [Bullet]
Set [Player] effect [Brightness] [200]
Wait [0.05] seconds
Set [Player] effect [Brightness] [100]
Wait [0.05] seconds
Set [Player] effect [Brightness] [200]
Wait [0.05] seconds
Set [Player] effect [Brightness] [100]


That code makes the player flash twice. Make sure you give [Player] the tint effect first!
B
9
S
3
Posts: 52
Reputation: 1,260

Post » Thu Jun 19, 2014 12:56 am

thats great! I felt really comfortable using the effect solution...
thank you both for helping!
B
3
Posts: 6
Reputation: 187

Post » Thu Jun 19, 2014 2:24 am

Or another alternative way is to create 5 animation sprites. Load it as an animation

If bullet hits Player --> Destrory bullet
--> Set Animation ("Animation name")
Image
B
31
S
7
Posts: 197
Reputation: 2,497


Return to How do I....?

Who is online

Users browsing this forum: hrisnz and 12 guests