Chapter 27: About the slide animation glitch problem

I think the problem occurs only because of the wrong frame rect.

In actionSlide(), if you replace this line of code:

penguin.frame = CGRect(x: penguin.frame.origin.x, y: penguinY + (walkSize.height - slideSize.height), width: slideSize.width, height: slideSize.height)

with this:

penguin.frame = CGRect(x: penguin.frame.origin.x, y: penguinY + (walkSize.height - slideSize.height)/2, width: slideSize.width, height: slideSize.height)

then you will not have the “glitch” problem and so you don’t have to subtract 0.02 from the animation duration.