Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Catacomber on June 22, 2009, 03:55:19 AM

Title: Color a sprite red
Post by: Catacomber on June 22, 2009, 03:55:19 AM
I'd like to color a sprite in the scene red while something is going on.  I searched the forum and found some script but it doesn't seem to work.

Any help is appreciated.

I found this script:

this.AlphaColor=MakeRGB("255, 255, 255, 255");


Title: Re: Color a sprite red
Post by: Darky on June 22, 2009, 04:41:56 AM
I don't know what your 4th value is for (it doesnt seem to be needed for RGB?), but anyway if you have a script file like with entitys you could specify it like this.

Done via WME 2D Demo, scenes/room/scr/book.script

Code: [Select]
on "LookAt"
{
this.AlphaColor=MakeRGB(255, 0, 0); // turn book red

// walk to the desk
actor.GoToObject(this);
actor.Talk("~"Wintermute Engine: User's manual.~"");
actor.TurnTo(DI_DOWN);
actor.Talk("Sounds interesting.");
actor.TurnTo(DI_UPRIGHT);

this.AlphaColor=MakeRGB(255, 255, 255); // restore full color
}

It's all about providing the right numbers :) Check a program like Photoshop to get the right RGB code of your color.
Note that 255, 255, 255 stands for pure white which from what I understand is for presenting unaltered colors as they are in your source image. That's most likely why it didn't work for you.
Also note in the code example if you abort the routine early it never will turn into full color again until you run through it again (in this case look at the book again and wait), so be careful how / where you place the restore to normal color.

Of course all this is just from a noob, so no warrantys ;) Have fun
Title: Re: Color a sprite red
Post by: Catacomber on June 22, 2009, 04:53:51 AM
Thanks.  I got it to work:

this.AlphaColor = MakeRGB(255, 0, 0, 255);

which is your script without the fourth parameter so your script works fine and so does mine.  : )  I'm not sure what the fourth parameter is but will search it in the forum.  I'd like to know what each parameter represents.

Thanks. : )
Title: Re: Color a sprite red
Post by: Azrael on June 22, 2009, 07:07:27 AM
RGBA

Red
Green
Blue
Alpha

;)
Title: Re: Color a sprite red
Post by: Catacomber on June 22, 2009, 05:48:39 PM
Thanks, Azrael!    :D
Title: Re: Color a sprite red
Post by: Darky on June 22, 2009, 06:54:58 PM
Thanks, too :)

I guess when you don't specify "Alpha" it just sets itself to a default of 255, right?
Title: Re: Color a sprite red
Post by: Mnemonic on June 22, 2009, 07:02:26 PM
Yes, exactly.