Apple Game Frameworks and Technologies: Misleading explanation of gloop end pos (p 62)

On page 62, right after the code snippet for func drop(dropSpeed: TimeInterval, floorLevel: CGFloat), is this line:

Here, you’re setting the initial position of the drop.

As the first explanatory line of text following the method it appears to be referring to the first line of code in the method: let pos = CGPoint(x: position.x, y: floorLevel). But this line is not setting the initial position of the drop. It is setting the end position of the drop to which it will animate. The drop starts up at the top of the screen and animates down to floorLevel.

The initial position of the drop is set elsewhere in spawnGloop(), which then calls drop.

2 Likes

Hi, David.

Thank you for pointing this out. I’ve updated the explanation, which will be made available in the next release.

However, for those reading now, the updated explanation reads as follows:

Here, you’re setting the end position of the drop; in other words, where you want the drop to land.

I also expanded the step-by-step that goes along with it—the updates noted in bold text:

  • First, you set the y-position using the input value stored in floorLevel.
  • Then, you add two scale actions to make the drop stretch a little; this gives it a drip-like > appearance.
  • Next, you create actions to fade-in and move the drop down the scene.
  • Finally, for some more visual appeal, you tweak the scale of the drop, and then run this sequence of actions. You give it a named key so that you can access this action later using its name.

Again, thanks for the feedback.

2 Likes