Opened 14 years ago

Closed 14 years ago

Last modified 8 years ago

#616 closed enhancement (fixed)

New special colour sprite

Reported by: historic_bruno Owned by: historic_bruno
Priority: Nice to Have Milestone: Alpha 3
Component: Core engine Keywords: colour, color, sprite, gui, renderer
Cc: Philip Taylor Patch:

Description

There isn't currently a way for scripts to change the color of an image. However, the GUI engine does allow "special" sprites to be defined at run-time. Currently only stretched images are supported, so I've modified this to add support for solid color sprites. This is useful for among other things, player colors, which may change from one game to the next, thus eliminating the need to hardcode N number of sprites ahead of time.

Example usage:

// Get an image object from the GUI
var imageObject = getGUIObjectByName("colourThing");
imageObject.sprite = "colour: 255 0 0 200"; // RGBA

The colour is specified in integer RGBA format like other GUI objects (0-255).

This should be useful for any GUI object with a sprite property.

One caveat as Philip notes, is that the sprite will be stored based on its name so every time a new sprite is created like this, it will be cached separately if even one character is different (even if it would appear identical).

Attachments (1)

colour_special_sprite.patch (1.9 KB ) - added by historic_bruno 14 years ago.

Download all attachments as: .zip

Change History (5)

by historic_bruno, 14 years ago

Attachment: colour_special_sprite.patch added

comment:1 by Kieran P, 14 years ago

Milestone: UnclassifiedBacklog

comment:2 by philip, 14 years ago

Resolution: fixed
Status: newclosed

(In [8431]) Add special "colour:r g b a" sprite syntax to GUI. Fixes #616, based on patch from historic_bruno.

comment:3 by Kieran P, 14 years ago

Milestone: BacklogAlpha 3

comment:4 by sanderd17, 8 years ago

Keywords: review removed
Note: See TracTickets for help on using tickets.