Gdevelop: Color tween on light object breaks preview

Created on 31 Aug 2020  路  6Comments  路  Source: 4ian/GDevelop

Describe the bug

Adding a color tween to a light object crashes the preview

To Reproduce

  1. Create a new Scene
  2. Add a light object, attach a tween behavior to it and place it in the scene
  3. Add a color tween action to the light object
  4. Hit run and the preview remains at 100% loading

Other details

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.

Possible solutions

  • Rewrite the getColor and setColor methods in the light extension to work with string values
  • Add a function to the tween extension which converts the integer array into a string
馃悰 bug

All 6 comments

cc @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 :)

Was this page helpful?
0 / 5 - 0 ratings