Adding a color tween to a light object crashes the preview
When a color tween is created on an object, the tween extension checks if the corresponding object exposes getColor and setColor methods and expects the return value to be of type string containing the rgb values as a semicolon separated list (For example: "255;0;125")
The light object exposes these methods but they are working with arrays of integers instead, which causes the tween extension to run into an error.
getColor and setColor methods in the light extension to work with string valuescc @HarsimranVirk
Good catch @Wend1go, we should probably also check the other objects - seems the BBCode Text object would need a fix too. As the light object is fairly new, I think it's no problem to update getColor to return a RGB string.
It's surely a bit less efficient (rather than returning the existing array of numbers), but I don't think it's traditionally used in critical performance paths. I'd favor consistency between objects for now.
Rewrite the getColor and setColor methods in the light extension to work with string values
setColor should be fine already I think, it's taking a "R;G;B" string.
Add a function to the tween extension which converts the integer array into a string
While it's a solution, there is also the question of should we handle hex colors, as should we handle them as string ("#11ff66") and as number ("#11ff66" it can be stored as an int: 1179494).
I suggest we normalize on setting/getting back "R;G;B" string for ease of use, and introduce later getColorAsHexNumber/setColorAsHexNumber if we want to have very efficient methods where all colors as treated as an int.
Fixed in f2287dd1ef224184ba55bc60654480790a98e92a :)
I'll see to make a bug fix release soon!
cc @blurymind
Yes, the BBText object is working with hex values and will also break the tween:
https://github.com/4ian/GDevelop/blob/master/Extensions/BBText/bbtextruntimeobject.js#L146
Same issue with the BitmapText
I'll fix the BBText object :)
Thanks for commenting on the BitmapText too!
I take care of the BitmapText, thx :)