0

I am hoping to be able to build a variable as a string but then have it actually be used as the correct type.

Example: I want to use graphics.setColor(color.red)

Is there a way to build the variable? String myColor = "Color." + Pull value at runtime myColor would then have a value of "Color.red"

So in my head the code would look like this

String myColor= "Color." + (color selection)

graphics.setColor(myColor.value());

So Ideally it would always set the color to whatever the current color selection is from a Gui

Can you do this?

Thanks

0 Answers0