Search code examples
korge

How to mirror dragonbones animation?


I make KorGE game with dragonbone animation. How to mirror this dragonbones animation? I want to character look to the right instead of the left:)

    val factory = KorgeDbFactory()

    val skeDeferred = asyncImmediately { Json.parse(resourcesVfs["Ubbie/Ubbie_ske.json"].readString())!! }
    val texDeferred = asyncImmediately { resourcesVfs["Ubbie/Ubbie_tex.json"].readString() }
    val imgDeferred = asyncImmediately { resourcesVfs["Ubbie/Ubbie_tex.png"].readBitmap().mipmaps() }


    factory.parseDragonBonesData(skeDeferred.await())
    factory.parseTextureAtlasData(Json.parse(texDeferred.await())!!, imgDeferred.await())

    val armatureDisplay = factory.buildArmatureDisplay("ubbie")!!.position(600, 720).scale(1)

    armatureDisplay.animation.play("walk")
    addUpdater {
        this += armatureDisplay
    }

Solution

  • SCALE_X = -1 gives mirror effect

    val SCALE_X=-1
    val SCALE_Y=1
    
    ...
    
    val armatureDisplay = factory.buildArmatureDisplay("ubbie")!!.position(600, 720).scale(SCALE_X, SCALE_Y)