sntx Posted September 21, 2020 Share Posted September 21, 2020 Dear community, Does Pixi ignore calls to set properties if the values are not changed? For example, let's say I have the following animation step function: step() { mySprite.x = someXVal mySprite.y = someYVal mySprite.angle = someAngleVal // etc... } Should I check if values have changed before setting them again? step() { if (mySprite.x !== someXVal) mySprite.x = someXVal if (mySprite.y !== someYVal) mySprite.y = someYVal if (mySprite.angle !== someAngleVal) mySprite.angle = someAngleVal // etc... } Obviously this example is simplified, it's purpose is just to illustrate my question. I'm thinking of the architecture of my application here and deciding what patterns to use. Another approach would be a dirty flag: step() { if (isDirty) { mySprite.x = someXVal mySprite.y = someYVal mySprite.angle = someAngleVal // etc... } isDirty = false } Re-stating my question: Do I need to implement a system for checking and setting only updated properties for PIXI objects or does PIXI already do this internally? As my application grows bigger, this would be an important decision, specially in terms of architecture and performance. Thanks! Santiago Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 21, 2020 Share Posted September 21, 2020 (edited) No, you dont have to do it. Some fields are done internally, some dont matter because they're processed every frame anyway, but of course there are big operations that shouldn't be called each frame. Avoid clearing&filling graphics every frame if you dont need it, for example. Edited September 21, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
sntx Posted September 21, 2020 Author Share Posted September 21, 2020 Hi Ivan, Thanks for your quick response! I knew about clearing and filling graphics, have been reading about that already. Can I read more about this subject somewhere? I know that some properties are fast (like setting tint, for example) and others aren't. Is there some sort of reference on this? Which properties are fast to set and modify and which ones are slow? Thanks again! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 21, 2020 Share Posted September 21, 2020 All props are fast. Usually its multi-lines calls of methods that are slow. > Can I read more about this subject somewhere? source-code. Unfortunately, our development process is faster than documenting. sntx 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 21, 2020 Share Posted September 21, 2020 Also, words "performance" and "optimization" usually are tied to "profiler" and "heapdump". You have to bump to a problem and identify it, before you figure out what code style is better for pixi. sntx 1 Quote Link to comment Share on other sites More sharing options...
Shukant Pal Posted September 21, 2020 Share Posted September 21, 2020 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.