caymanbruce Posted March 8, 2018 Share Posted March 8, 2018 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? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 8, 2018 Share Posted March 8, 2018 nvm Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 8, 2018 Share Posted March 8, 2018 Go to pixijs github issues, there was explanation for that technique. caymanbruce 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 8, 2018 Share Posted March 8, 2018 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. caymanbruce 1 Quote Link to comment Share on other sites More sharing options...
Daniel Parokonnyy Posted March 8, 2018 Share Posted March 8, 2018 Try PIXI.extras.AnimatedSprite Quote Link to comment Share on other sites More sharing options...
caymanbruce Posted March 9, 2018 Author Share Posted March 9, 2018 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? Quote Link to comment Share on other sites More sharing options...
themoonrat Posted March 9, 2018 Share Posted March 9, 2018 call .update() on the texture (the texture that is created with the canvas as the source) ? Quote Link to comment Share on other sites More sharing options...
caymanbruce Posted March 9, 2018 Author Share Posted March 9, 2018 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. Quote Link to comment Share on other sites More sharing options...
xerver Posted March 9, 2018 Share Posted March 9, 2018 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 caymanbruce 1 Quote Link to comment Share on other sites More sharing options...
caymanbruce Posted March 9, 2018 Author Share Posted March 9, 2018 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? Quote Link to comment Share on other sites More sharing options...
xerver Posted March 9, 2018 Share Posted March 9, 2018 3 hours ago, caymanbruce said: Ah I see. Thank you for that. I thought update() will clear the texture before I redraw. What happens in the update() method? We upload the texture to the GPU, we never draw to your canvas or even open a context on it. caymanbruce 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.