KorGE

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Tweens of anything else but position/rotation...

    General
    2
    3
    63
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      LuxxorOne last edited by

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

      Thanks.

      1 Reply Last reply Reply Quote 0
      • soywiz
        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.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.

        1 Reply Last reply Reply Quote 0
        • L
          LuxxorOne last edited by

          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!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post