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

Hi @dpalme, I’m not sure why the game is locking up on you. I’m able to play the finished game endlessly on the simulator and my devices (iPhone 7 and iPad Pro.) I’ve used a variety of simulated devices (7, 8, 6, iPad, etc.) and they all loop through to the first level after completing the last level.

I don’t think possible swaps: [] is a problem. Whenever you hit shuffle, the game prints all possible swaps to the console like this: possible swaps: [swap type:cupcake square:(4,4) with type:sugarCookie square:(4,5)]. If there aren’t any possible (which happens on Level_4), you’d see that empty Set printed.

This sounds like a great start, @ma2412!

Hi @ma2412. The sprite image comes from the CookieType enum, so if you’ve changed the type, you should have the information to update the sprite. I would add a function to GameScene to update the sprite.

Also in GameScene.swift, you also may need to update func addSprites() to use a var instead of a let, since you’re updating the sprite. Change let sprite = SKSpriteNode(imageNamed: cookie.cookieType.spriteName) to be var sprite = SKSpriteNode(imageNamed: cookie.cookieType.spriteName)

Here is what I’m going to do, I’ll take your copy (fresh download) and replace my code with yours, and then retest it again. Provided everything is working, I’ll replace each change I had implemented one by one and go from there.

Is there anything special about the json files ? Any gotchas that I need to be watching for? IE: adding new levels.

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

I was able to get it working, not sure what the differences were in the end. I took your version and then went back and added each piece of mine in one at a time, testing after each update.

Thanks for the help

As a follow up question, are you aware of a tut or maybe point me in the right direction on how to create a game map similar to what candy crush has ? It seems as though it must be downloading assets on the fly since it goes on like forever.

Hi, this project does not work in XCode 10 beta, do you know why and do you think it will work in the final XCode 10?

The tiles do not get the correct int values (tile_1, 2, etc) for matching the assets (red x’s) and the gameplay is not useable.


@kevcol Do you have any feedback about this? Thank you - much appreciated! :]

Great tutorial. Back again after a bit of a break. With some news.

The “Failed assertion >=4” error that is crashing the game on the Simulator can be stopped by commenting out //run(invalidSwapSound) in GameScene.swift. I also have // run(swapSound) commented out just above it. Don’t know if that was causing problems, but the second one certainly is a problem.
Edit; Yes, I did the same in the Obj-C version, and commented out the swapsound and invalidswapsound, and it works on the simulator in both cases

I haven’t yet got to it to find out why that works - but just thought I’d let you-all know.

I found a (temporary) solution - please see my latest post.

Hi again!

any news about to get this working with the new swift 4.2?
i have some Problems with the hasable-thing and i readed this article:
i do not understand this

any clue what do i have to change to show the corect “tile_…” images? they should have 1 to 9 at the end but the got weird negative random numbers as they need some new hashable-coding for swift 4.2

many thanks!

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

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!