Performance impact of rendering text.

Discussion and feedback on Construct 2

Post » Sat Apr 26, 2014 4:58 am

Hey there!

I was wondering if there's any big difference in using pre-rendered text (images of text) vs actually render the text on run time. (this for texts that don't change, or change just once per layout, like text that need to be in different languages, i could use an sprite with frames instead of text, assuming it has a significant impact on performance)

Also, when the text is the same every tick, and it's set to "set text" in an always condition, does construct re-render it every tick or, since it hasn't change, it leaves it alone?
This seconds question is for things like "health points". where you set the text to, for example; player.hp.
I'm guessing the game does render the texts again and again, and would be best to just set text when needed to, right? I've feel rendering text is a lot heavier on performance than it seems.
B
43
S
12
G
6
Posts: 446
Reputation: 6,807

Post » Sat Apr 26, 2014 5:21 am

Dom Objects don't render in the canvas. So they add terrible overhead. While desktop's can soak this. Any mobile game shuold avoid them like the plauge.

Sprites Fonts should be the only one considered.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,038

Post » Sat Apr 26, 2014 8:26 am

Use Sprites Fonts or sprites.
B
159
S
27
G
17
Posts: 916
Reputation: 32,664

Post » Sat Apr 26, 2014 8:27 am

@jayderyu sorry, but I'm gonna need clarification :S

you mean that objects like the Text objects are incredible hard to process? and I should go with a sprite of text instead?

Meaning that events like "every tick; set text to X" will drop fps like crazy?

I also found this Article that pretty much says what you said, i think...

I had never though about any of this prior tonight, and my game is actually full of events with always conditions, specially text objects and frame setting on sprites...
So i'm going to have to implement a ton of "checkers" and functions to replace all the "always". It should really improve performance though =O
B
43
S
12
G
6
Posts: 446
Reputation: 6,807

Post » Sat Apr 26, 2014 8:30 am

@iceangel thanks, i see that now =O

do you have any information regarding sprites font vs sprite performance? should they be identical? (i speculate the pre-rendered sprite should perform a little bit better)
B
43
S
12
G
6
Posts: 446
Reputation: 6,807

Post » Sat Apr 26, 2014 8:37 am

In my opinion goes better using sprites that sprites font especially if you are using CocoonJS.
B
159
S
27
G
17
Posts: 916
Reputation: 32,664

Post » Sat Apr 26, 2014 8:40 am

@iceangel it seems I have some objects to replace and a ton of events to modify now =P!
B
43
S
12
G
6
Posts: 446
Reputation: 6,807

Post » Sat Apr 26, 2014 8:42 am

Using sprites is more work but you are better performance.
B
159
S
27
G
17
Posts: 916
Reputation: 32,664

Post » Sat Apr 26, 2014 10:25 am

I believe there is a big difference between text and textbox. Textbox is a dom element. I think (please correct me if I'm wrong here) is rendered on the canvas and so it is efficient (the implementation is scirra's). Having said that, spritefont is best because you get consistent look across all browsers, platforms.
B
12
S
3
G
4
Posts: 57
Reputation: 3,186

Post » Sat Apr 26, 2014 11:36 am

@jayderyu - the Text object is not a DOM object. It's a pure canvas feature like Sprite.

@Sargas - if the contents of the Text object is not changing, it renders as fast as a normal Sprite. However changing the text causes re-flow of the text, and in WebGL mode a copy-to-texture which can be slow. Generally if you avoid changing text's contents every tick it's fine. Even if you need to keep changing text, just change it on a timer instead (e.g. once a second). Alternatively you can use a Sprite Font which never needs the possibly slow copy-to-texture that Text object needs to do when its contents changes.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,361

Next

Return to Construct 2 General

Who is online

Users browsing this forum: newt and 5 guests