Adding animations and controls in our Platformer game
After discussing about the SKAction
class and various methods to add controls in our game, it's time to revisit our Platformer game and implement some of them.
Adding actions
Now, it's time to add actions in our game. Let's start with adding animation to the player and block collision. Until the last chapter, there was no collision effect between the player and the blocks.
Here we will add collision between the block and the player. Along with this, we can make the player die in an animated way. We can denote the animation after the player and block collision as a player death animation.
First of all, we will update the maximum size of the X-axis for the blocks, because currently, the blocks are being destroyed before the end of the running bar. Hence, we will replace the respective code with an updated one.
Replace self.blockMaxX = 0 - self.block1.size.width / 2
with self.blockMaxX = 0 - self.runningBar.size.width
in the addBlocks()
method...