How do I replace object color and not impact performance?

Get help using Construct 2

Post » Sun Sep 24, 2017 2:19 pm

I am using lots of sprite fonts in my game. All sprite fonts are white and when I need text in a different color I use "Set color" effect.
This allows re-using same sprite fonts, instead of adding lots of duplicate sprite font objects in different colors.

Today I tested my game on an old mobile phone and realized that it has become really slow. It only took me about 5 hours to figure out that the "Set color" effect is causing this :(
I removed it from all objects and the FPS returned to comfortable values.

Is there another way to replace color of sprites or sprite fonts, that would not impact performance?
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,386
Reputation: 84,399

Post » Sun Sep 24, 2017 2:29 pm

You could try Paster: plugin-paster_t88750?&hilit=paster
You'd draw into the paster object with set colour once, then use the Paster object on screen. You have to deal with the added complexity of using the paster objects on-top, or instead of, the real objects.
ImageImageImage
B
72
S
22
G
290
Posts: 3,886
Reputation: 159,513

Post » Sun Sep 24, 2017 2:42 pm

Or just use another Spritefont object.
B
179
S
50
G
208
Posts: 8,721
Reputation: 128,810

Post » Sun Sep 24, 2017 2:55 pm

@blackhornet, thanks, it's an interesting plugin, but I don't think it works with sprite fonts. I tried it and it draws the entire sprite font (whole character map of this sprite font) instead of my text. And even if it does work, this would probably be an overkill for my task.

@newt, I have about 10 sprite font objects already, I really don't want to create 20-30 more just with different colors..
Of course I'll have to do it if I don't find a better solution.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,386
Reputation: 84,399

Post » Sun Sep 24, 2017 3:47 pm

http://www.blackhornettechnologies.com/Construct2Stuff/dop2000_SpriteFontAndPaster.capx
I can't argue about it being over-kill, but it does work, as long as you draw on-screen. (I actually logged a bug about not being able to move everything offscreen to draw, as the spritefont implementation over-optimizes by not drawing outside of the viewport).
ImageImageImage
B
72
S
22
G
290
Posts: 3,886
Reputation: 159,513

Post » Sun Sep 24, 2017 4:24 pm

Alternatively use a sprite with frames for letters, and animations for colors.
#goodoldays
B
179
S
50
G
208
Posts: 8,721
Reputation: 128,810

Post » Sun Sep 24, 2017 4:44 pm

@newt, I'm so glad I didn't know about Construct 2 in those good old days :)

@blackhornet, wow it does work! And when I move the sprite font object off the screen after pasting, the performance on mobile is good. Still not sure if I want to use it with all my sprite fonts, but will keep it in mind.Thanks!
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,386
Reputation: 84,399

Post » Mon Sep 25, 2017 10:24 am

dop2000 wrote:@newt, I'm so glad I didn't know about Construct 2 in those good old days :)

@blackhornet, wow it does work! And when I move the sprite font object off the screen after pasting, the performance on mobile is good. Still not sure if I want to use it with all my sprite fonts, but will keep it in mind.Thanks!

Hey buddy. I have yet to check out BHT's example but I'm currently experimenting simply using
Sprite Fonts + Additive Blend Mode

https://www.dropbox.com/s/6ci43ij38e0kd ... .capx?dl=0

It's very easy to you a simple single box sprite with many animation frames of different colors to display achieve absolute colors when placed on top of your sprite font.

With gradual color change on the other hand, I created a top colored non-transparent layer, set the whole layer to "Additive Blend" and just manipulated the r,g,b (x,x,x) colors of the background.
This one works pretty well but only works if you put the color layer and sprite font layer at the 2 bottom most layers.
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 832
Reputation: 20,807

Post » Mon Sep 25, 2017 10:57 am

@MPPlantOfficial
I can't load your example, it requires "Flood Fill" behavior by rexrainbow, which I can't find anywhere.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,386
Reputation: 84,399

Post » Mon Sep 25, 2017 11:08 am

dop2000 wrote:@MPPlantOfficial
I can't load your example, it requires "Flood Fill" behavior by rexrainbow, which I can't find anywhere.

Don't worry. As I'm typing this I'm creating an even better one that uses only Sprites. It'll be ready in about and hour. :D
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 832
Reputation: 20,807

Next

Return to How do I....?

Who is online

Users browsing this forum: ghzmxls, guannstar and 19 guests