Stencyl 2.2.0 - set font colour

set your desired font color

1) Your font
2) set font color to []
3) draw your desired text at your desired position 

1) basic






























 2) mixed with code for in-game colour adjustment - make sure the 3 game attributes are available
  
programming behavior,
image above: applies to the adjusting button, the "Always" event is optional because it is a pop-up option subbuttons:

for the mouse based info panel: http://stencyl-nator.blogspot.my/p/stencyl-info-panel.html

image below: applies to any button with info panel


code:
a) g.setFontColor(Util.RGBToHex(255,255,255));
b) g.setFontColor(Util.RGBToHex((getGameAttribute("game attribute red") as Number),(getGameAttribute("game attribute green") as Number),(getGameAttribute("geme attribute blue") as Number)));

added in 15 December 2015
Even more complicated, this time we have things to do with list, which is useful to games multiple save slots, it is a code

getting list:
Number("" + (getGameAttribute("Your list game Attribute here") as Array)[(getGameAttribute("your number game attribute here") as Number)])

the colour setting code:
g.setFontColor(Util.RGBToHex(0,0,0)); 

/* the colour code with list for multiple save slots */
g.setFontColor(Util.RGBToHex(Number("" + (getGameAttribute("red power") as Array)[(getGameAttribute("save slot") as Number)]),Number("" + (getGameAttribute("green power") as Array)[(getGameAttribute("save slot") as Number)]),Number("" + (getGameAttribute("blue power") as Array)[(getGameAttribute("save slot") as Number)])));

 KEEP THIS IN MIND: before any values can be used in any list it must be reset in the game. Use this setter in attributes>lists
 

WARNING: please do not miss the ";" at the end of each line or compilation error will occur







No comments:

Post a Comment