-3

My game play is an animal jumping over holes. If it hits a hole, it loses life. But if it makes three successful jumps it unlocks an achievement.

How do I detect a successful jump? I have the logic for detecting failed jumps using SKPhysics​Contact & SKPhysicsBody.

animal ========>hole 1 ========>hole 2 ==========>hole 3======[unlocks achievement]==============>

I can use touches begin and touches end but it gets complex because it can do other fake jumps (not over hole).

rmaddy
  • 314,917
  • 42
  • 532
  • 579
merloin
  • 31
  • 3

2 Answers2

0

You could detect a successful jump in a similar manner to your hole detection. Simply assign your platforms a separate SKPhysicsBody category bitmask that you check against. Once you detect a contact and the platform touched is past Hole 3, then unlock the achievement.

Stoyan
  • 320
  • 1
  • 9
0

Method 1) Presuming you use separate SKNode for each platform the animal jumps on, keep track of the last platform (SKNode) the animal stood on before the jump and compare to the platform (SKNode) it landed on after each jump. If pre-jump platform Node is different from landing platform Node the animal performed a successful jump.

Method 2) If the level is based on coordinates, you can have an NSArray with hole coordinates and if the animal coordinates before and after the jump are either side of one of the holes, the jump is successful.

Sulevus
  • 669
  • 5
  • 13