maxgribov/Spine

applySkin to running animation

gholias opened this issue · 2 comments

hi, I'm trying to run a very simple test: Change the skin of a running animation with a touch in the screen.
This is my code:

var character: Skeleton!
override func didMove(to view: SKView) {        
        character = Skeleton(fromJSON: "zombie", atlas: "Zombie", skin: "zombie1")
        self.addChild(character)

       if let walkAnimation = character.animation(named: "Idle") {
            character.run(SKAction.repeatForever(walkAnimation))
        }
}

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {        
        character.applySkin(named: "zombie2")        
    }

When I run the app, I can see the Skin zombie1 and the Idle animation running.
When I tap the screen, it looks like the zombie2 skin images are applied to the animation, but the images from the skin zombie1 are still visible.

Screen Shot 2020-05-29 at 12 33 07 PM

Screen Shot 2020-05-29 at 12 33 13 PM

In the Spine app, I can see the correct skin is applied to the animation when I toggle them, so I dont think it is a problem with the Spine json.
Am I doing anything wrong? Should I remove the running animation before changing the skin?

Thank you

check if you use zombie2 skin instead of zombie1 initially, will your zombie2 display correctly?

@maxgribov The same problem happens, with a little different order of the images
Simulator Screen Shot - iPhone 11 Pro Max - 2020-05-30 at 10 09 13