KorGE

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

    Why the text widget centerOn() method is notwoking?

    General
    2
    2
    60
    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.
    • Jero Wang
      Jero Wang last edited by

      The code:

          val font = resourcesVfs["fonts/clear_sans.fnt"].readBitmapFont()
          text("2048", cellSize * 0.5, Colors.WHITE, font).centerOn(bgLogo)
      

      runJvm:
      16622c21-3656-4dfc-a38b-fb7768a0bcc4-image.png

      Please help me to solve this problem, thanks!

      1 Reply Last reply Reply Quote 0
      • Yuri Volkov
        Yuri Volkov last edited by

        I also noticed that centerOn stopped working (at least in some cases) after some KotGe library upgrade.
        And I easily changed this to the manually calculated positioning ( position(x, y) )
        E.g. in https://github.com/andstatus/game2048/blob/master/src/commonMain/kotlin/org/andstatus/game2048/presenter/Block.kt I changed:

        centerOn(this@graphics)
        

        to

        position(cellSize / 2, cellSize / 2)
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post