Group Group Group Group Group Group Group Group Group

raywenderlich.com Forums

How to Make a Game Like Candy Crush with SpriteKit and Swift: Part 3

Updated for Xcode 9.3 and Swift 4.1. Learn how to make a Candy Crush-like mobile game, using Swift and SpriteKit to animate and build the logic of your game.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/58-how-to-make-a-game-like-candy-crush-with-spritekit-and-swift-part-3

Great tutorial! Learned a lot. Code worked great.

1 Like

I see we still have this error when trying to run on the simulators. It runs, but when you try to move a tile this happens.
failed assertion: inChannelsPerFrame >= 4

It runs fine on an attached device

@kevcol Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi @shanghaitimes, are you still having this problem?

Hi there - many thanks for this great tutorial!

i have the same error as shanghaitimes…
on my iPhone 7 everything works, but in the Simulator i always got this error as soon i want to swipe.
I have the newest Mac OS and Xcode.

many thanks for your hints to solve this issue!

is there a way to access the cookie type when in animateMatchedCookies?

i still have this issue, does anybody have a solution for that?

I also notice that the game locks up after it plays the last level. Never reverts back to the first level.

Hi @ma2412! I am not seeing that error when running the downloadable materials “CookieCrunchPart3-Final” (linked from the top of the tutorial and here: https://koenig-media.raywenderlich.com/uploads/2018/04/CookieCrunchPart3-1.zip).

Can you give that project a spin and let me know if you still see the error?

If the downloadable project runs error-free, you can compare that to your project. Or send me your project as a zip file and I’d be happy to take a look.

Cheers,
Kevin

Hi @dpalme! I am not seeing that error when running the downloadable materials “CookieCrunchPart3-Final” (linked from the top of the tutorial and here: https://koenig-media.raywenderlich.com/uploads/2018/04/CookieCrunchPart3-1.zip).

Can you give that project a spin and let me know if you still see the error? (You can give yourself more moves per level by editing “moves” in the level json – that Level_4 is a killer!)

If the downloadable project runs error-free, you can compare that to your project. Or send me your project as a zip file and I’d be happy to take a look.

Cheers,
Kevin

Hi @dpalme! Yes, you can access cookie.cookieType. For example, you can add a print statement after if let sprite = cookie.sprite to print out the cookie type to your console

print(cookie.cookieType)

Hi Kevin,

thanks for your reply.
The error still accours, but only in the simulator and not on real devices.
Nevermind i solved it, as is commented all sound out - then it will work.

Hi Kevin,

i want to add some special chains like a “T”-shape to get a small bomb like in other 3-match-games.

As i think i have to do:

  • define a bomb in cookie-swift (spriteNames)
  • in chain.swift: add enum case for the bomb
  • in level.swift: add a new private func where i loop something to detect my T-shape
  • in func removeCookies: set one cookie (those one i have swapped to) NOT to nil and replace it with the bomb

am i missing something?

many thanks for your help or your hints to get me in the right direction!

Yep still get the same thing with the final zip. The only thing I changed in the level 3 and 4 was the number of attempts allowed.

I’ll download a fresh copy and try it again just to make sure.

I did notice in the console that it kept printing - “possible swaps: []”

Hmm, OK. Which simulated device were you using?

I tried it in the sim and on my phone, 7 & 8 and a 6 (actual phone)

I can change the value of the CookieGrid from one Cookie type to another, but how can i also change the sprite of the cookie to the new picture within level.swift?
many thanks!