Tweens of anything else but position/rotation...
For example: How can I do tweening of colors or other parameters?
I tried to read up on "bound callable references" but still don't really understand them in this context.
I get it when I write something like this:
fun addTwo(x: Int) = x + 2 var list = listOf(1, 2, 3, 4).map(::addTwo) // # => [3, 4, 5, 6] println(list)
But I don't understand this:
You have to use bound callable references to define properties that will change"
Can someone give an example in KorGE context how to tween a non-trivial/arbitrary parameter please (like color?
I also don't get how to get bytes data from RGBA color in general btw. )
soywiz last edited by
The same way as the other properties. Colors and angles are specially handled here: https://github.com/korlibs/korge/blob/16aac42d6cf0e4eed19e088e12b73282661cf0f4/korge/src/commonMain/kotlin/com/soywiz/korge/tween/tween.kt#L242-L248
The way for doing that is:
view.tween(view::colorMul[Colors.RED, Colors.BLUE]) view.tween(view::rotation[180.degrees])
Also note that in addition to views you can interpolate any other property just using the [...] syntax.
The view from
view.tweenis the view that will register an updater, and as long as that view is on the stage, it will interpolate the properties on each frame.
I just found that out by myself, lol.
This is so easy, I was looking to get the bytes r/g/b separate...