How Phaser can make a flashing animation of sprite?

here is an example of such animation https://www.youtube.com/watch?v=wxd9NZrt73o&feature=youtu.be

I’ll be appreciated of any hints or googles.

Thank you :slight_smile:

Try setTint() in combination with a tween.

Link to Sprite docs

thank you good sir.

Diving into it…

Actually, I just tried it and it does not work :confused:
Guess it is not that easy, sorry

This works :slight_smile:

3 Likes

for some reason it doesn’t work for me

https://monosnap.com/file/n851DenQvOhy2pGYtmlgwiNiM2d1Wc

I think it is because the sprite has a big transparent sides. No?

It looks like you are not using the same scale for sprite and graphics.

I don’t use scale at all

https://monosnap.com/file/uRuyTtXekbcvtnoacldObYu5xvfXyB

the example is absolutely the same just with me assets

Can you please upload your image and I will test it as soon as I’m home on my computer? (In about 3-5 hours)

Edit:
Ooh I just saw that you are using an Atlas. Maybe because of this it does not work? Anyways, I will test it later if this topic has not been resolved till then.

yes, you right.

I’ve just tested using a single image without multiatlas and it works.

For some reason this method doesn’t work with atlas

I was trying to use frame data. The result gets a bit better, but not perfect still

https://monosnap.com/file/gBILhCWK3HdoQyvfjTNfryRLtS8Qcn

https://github.com/oduvan/phaser3-my-examples - here is a project, you can simple npm start it

here is an actual code I’m experimenting with https://github.com/oduvan/phaser3-my-examples/blob/master/flashing.html

assets can be found here https://github.com/oduvan/phaser3-my-examples/tree/master/assets

I have fixed it!

You where not that far away from the solution. You have to use

graphics.fillRect(frame.x, frame.y, frame.cutWidth, frame.cutHeight)

1 Like

it works perfect

Thank you

Looks like this method work for WebGL only, but doesn’t work for canvas.

This is how changing to canvas looks like https://monosnap.com/file/f3ycfQ8ub926OletEVo2Tc5xxH2l4l

Many features work only with WebGL. WebGL is just more powerful than canvas. I personally do not see any use case for the canvas renderer any more. WebGL support is very good and works well on almost all devices. See webglstats.

Or do you have an use case where you absolutely need canvas?

Thank you for the link with stats.

I’ll focus on WebGL as well then. I had an issue with using WebGL with Electron, which was fixed by simply switching to canvas, but I’ll probably get back the that issue if statistics is so dramatic.

Hope you’ll find a way to fix it. I have never used WebGL in conjunction with Electron before.

1 Like

with such an awesome community support - no way I can’t find it :slight_smile:

Thanks again for your help.

You’re welcome :hugs:

I do also love Phaser and its community. For me Phaser is the best game framework!

It makes me very happy to help others while learning new things :heart_eyes:

1 Like