User Tools

Site Tools


orxCOLOR and how to colour an object

Sometimes you might want to colour an object. This is very handy for font objects if you want to do some highlighting, or for many types of orx object. The function you need is: orxObject_SetColor but working it seems tricky at first.

The following code should serve as a simple example:

	orxVECTOR vec;
	vec.fX = 1.0; //full red
	vec.fY = 0.5; //half green
	vec.fZ = 0;   //no blue = orange
	orxCOLOR colour;
	colour.vRGB = vec;
	colour.fAlpha = orxFLOAT_1; //set alpha required to stop your object from becoming fully transparent.
	orxObject_SetColor(MyObject, &colour);

I'll change this tutorial to make a function where you can add actual RGB values, ie 0 - 255 as this is more intuitive for some. But for now, you get the idea that you need to create a vector of values between 0 and 1 for each colour component, set the vRGB value with the vector, set the alpha (required) and then use on orxObject_SetColor.

tutorials/community/sausage/orxcolors.txt · Last modified: 2017/05/30 05:50 (8 weeks ago) (external edit)