mise Posted October 23, 2018 Share Posted October 23, 2018 perormance of this example goes to zero asymtotically but runs very smooth when cache=false: same thing if you create new Text every update. var text: any; game.module( 'game.main' ) .body(() => { game.addAsset('font.fnt'); game.Debug.enabled = true; game.createScene('Main', { init: function() { text = new game.Text('', { font: 'font', cache: true }); }, update: () => { text.setText(Date.now()); } }); Quote Link to comment Share on other sites More sharing options...
enpu Posted November 3, 2018 Share Posted November 3, 2018 This is actually expected behavior. When you set cache property to true, the engine will render the whole content into one big sprite and use that for rendering instead of using one sprite for each character. Every time you change the text it has to render the big sprite again. So i would suggest to use cache only on text that you don't change constantly. Quote Link to comment Share on other sites More sharing options...
mise Posted November 5, 2018 Author Share Posted November 5, 2018 Yeah, I figured that might be the case. That at least explains why it would be slower in this case. I still don't see why performance would need to go down though. Are we keeping all cached sprites around forever by default? What would be the reason for keeping old ones around at all? Maybe if we switch between a couple of same texts, but at that point I would just swap visibility on multiple instances which could be way faster anyway. I am mostly just curious at this point 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.