September 2018
Intermediate to advanced
434 pages
8h 47m
English
To make sure that the correct animation gets played when the player runs and jumps, we have to extract the run and jump animations from the collada file.
In the Hero class's create function, after updating the anchor point, add the following code to get the run and jump animations:
// get the animation keys and store it in the anims let animKeys = monsterNode.animationKeys.first let animPlayer = monsterNode.animationPlayer(forKey: animKeys!) let anims = CAAnimation(scnAnimation: (animPlayer?.animation)!) // get the run animation from the animations let runAnimation = Hero.animation(from: anims, startingAtFrame: 31, endingAtFrame: 50) runAnimation.repeatCount = .greatestFiniteMagnitude runAnimation.fadeInDuration = 0.3 ...
Read now
Unlock full access