Fruity Crush Saga App Diary: Day 6

heart shape of fresh berries

In order to provide a visual cue to the player the selected swiped fruit should be highlighted momentarily in order to indicate which fruit the player is about to swap. This selection highlighting animation can be achieved by temporarily placing a highlighted version of the sprite on top of the current sprite and having it along for the ride in the swap animation and eventually fading out.

First, we’ll need to add an SKSpriteNode property, selectionSprite, to the Game Scene to have access to the selected sprite.

Then a new showSelectionIndicatorForFruit() function is needed that gets the name of the highlighted version of the sprite image from the fruit object and puts that texture on the selectionSprite property. The selectionSprite is added as a child of the currently selected sprite so that it tags along in the swap animation implemented yesterday.

The reverse function of hideSelectionIndicator() is simply an SKAction sequence that does a fadeOutWithDuration and then removesFromParent.

These functions are called in the touch functions of:

  • touchesBegan() where we need to showSelectionIndicatorForFruit,
  • touchesMoved() where we need to hideSelectionIndicator, and
  • touchesEnded() where we also hideSelectionIndicator if the player just taps a selection but doesn’t make a move.

Building and running the current code provides the player with the desired selection highlighting animation.

Tomorrow, we’ll update the array creation such that we don’t get chains of three in a row at the onset since that makes the puzzle of finding matches kind of trivial.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s