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]

    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. )


  • The same way as the other properties. Colors and angles are specially handled here:

    The way for doing that is:

    view.tween(view::colorMul[Colors.RED, Colors.BLUE])

    Also note that in addition to views you can interpolate any other property just using the [...] syntax.
    The view from view.tween is 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...
    Very cool!

Log in to reply