How do I change font colour using an array?

0 favourites
  • 5 posts
From the Asset Store
Creepy Sprite Font suitable font for your Dark/Horror/Halloween games.
  • Hi,

    Is it possible to change a font colour using this setup, which the json array's 0 row containing dialogue, the 1 row containing animations, and the 2 row (hopefully) containing colour data? Using rgb either doesn't work or turns all text black.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Color data consists of 3 values. So if you want to store them in one cell, you will have to store them as a string of text. For example "255,0,255" (but without the quotation marks). And then separate them into 3 numbers for rbg() expression:

    Set colorVar to Array.at(0,2)

    Sprite set color to rgb(int(tokenat(colorVar,0,",")), int(tokenat(colorVar,1,",")), int(tokenat(colorVar,2,",")))

    .

    Another option is to pre-calculate all color values. For example, rgb(255,0,255) returns number 16711935. So you can store it in the array and use directly in "Set color" action, without the rgb expression.

  • Thanks igortyhon and dop2000.

    dop2000 I've been getting inconsistent results using the second method. Sometimes the colour looks completely different like in the screenshot below, where red displays as blue. Could you explain why this happens?

  • I've been getting inconsistent results using the second method. Sometimes the colour looks completely different like in the screenshot below, where red displays as blue. Could you explain why this happens?

    You can't use online tools. C3 uses some custom formula for colors, so you need to convert r+g+b values with rgb() expression. Make a little project with 3 text inputs and a button.

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