Jump to content

Is it possible to make a sprite based on a canvas texture which is changed by the system time?


caymanbruce
 Share

Recommended Posts

It seems the `Sprite` in PIXI only supports static texture. What if I have such a sprite which is originated from a canvas element with radialgradient color, and I want the radius of the gradient change continuously based on current time? Say like a bubble from small to big and then small again. Something like that. Can I use sprite for that purpose?

Link to comment
Share on other sites

13 hours ago, ivan.popelyshev said:

One of possible ways is to call "renderer.textureManager.updateTexture" manually every time it changes. In pixi-v5 its easier. Sorry, im lazy today, you have to use search over github issues.

I've tried. But I can't make it update. Anything I have missed?

 

Link to comment
Share on other sites

3 hours ago, themoonrat said:

call .update() on the texture (the texture that is created with the canvas as the source) ?

Hi thanks I have also tried that method but it is updating the baseTexture and the result is weird. See my demo for the code I commented out.

Link to comment
Share on other sites

58 minutes ago, xerver said:

It works fine when you call sprite.update(). You just forgot to clear your canvas when you drew to the canvas in your lightenGradient function.

Working pen: https://codepen.io/anon/pen/mxyezY

 

Ah I see. Thank you for that. I thought update() will clear the texture before I redraw. What happens in the update() method?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...