How do I replace object color and not impact performance?

0 favourites
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You could try 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.

  • Or just use another Spritefont object.

  • 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.

  • 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).

  • Alternatively use a sprite with frames for letters, and animations for colors.

    #goodoldays

  • 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!

  • newt, I'm so glad I didn't know about Construct 2 in those good old days <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    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.

  • MPPlantOfficial

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

  • 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.

  • MPPlantOfficial

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

    Updated. Try this one: https://www.dropbox.com/s/at4bg7tjp2w12 ... .capx?dl=0

  • Nice example, thanks!

    But do I understand correctly that it only works on white background?

    Additive blend affects everything underneath this sprite, right? I have a dark blue night sky as a background in my game, so this won't work for me

  • MPPlantOfficial

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

    Here's one using sprite boxes only: https://www.dropbox.com/s/olzoy0p4wfzwg ... .capx?dl=0

  • Hey MPPlantOfficial

    Not sure if you've seen my previous question.

    Is it possible to recolor text with additive blend if I have a background in my game which is not white?

  • Hey MPPlantOfficial

    Not sure if you've seen my previous question.

    Is it possible to recolor text with additive blend if I have a background in my game which is not white?

    I've not tried it myself. Why don't you experiment for a bit?

    Maybe there's a way of applying blend so that only 1 or 2 layers are affected

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)