storing color as a single object
Monkey Forums/Monkey Programming/storing color as a single object
| ||
Hi, Is this possible? (this is my sudo code that I would like to be able to do)... Global LovelyColor=[215,35,222] SetColor LovelyColor It would make is really easy for reusing colors in my app. Thank you |
| ||
no but you can roll your own function:Global LovelyColor:int[] = [215,35,222] SetColor(LovelyColor) Function SetColor:Void(c:int[]) mojo.SetColor c[0],c[1],c[2] End Function |
| ||
I have something similar that I use a lot. I have it as a submodule in my Abu framework but here it is seperately: You can put it either in your project folder or the modules folder, and then add this to the top of any file that uses it: Import mojomodifications Alias SetColor = mojomodifications.SetColor Alias Cls = mojomodifications.Cls Then I make color constants like this: Const COLOR_WHITE:Int = $FFFFFF Const COLOR_GREEN:Int = $00FF00 ... Cls(COLOR_WHITE) SetColor(COLOR_GREEN) Maybe hex codes aren't your thing but I find them useful :) EDIT: I've added the array strategy. |
| ||
I don't know what you you mean. my example works fine here v67b. |
| ||
Hmm, I thought I remembered having a problem overloading functions like that before but I was mistaken. Sorry. |
| ||
I had overloading issues too, though I imagine they could be overcome using Alias. As a RightPondian, my solution was to make a SetColour() function. |