Is it possible to remove same type neighbour cookies as in below illustrated.
if yes then how?
Hi @mfaarkrog,
I think this tutorial is really amazing and helpful!
But why do I get the error: "Extra argument âcompletionâ in call?
scene.animate(swap: swap, completion: handleMatches) //Error: Extra argument âcompletionâ in call
I figured out that since Swift 3.0.1 it have to be âscene.animate(swap, completion: handleMatchesâ), but the error is still there. Itâs driving me crazy. I try to get it to work since two hours.
Please help me! :]
Hi @liberatordg,
I ran into the same issue as I was walking through the tutorial, and you are correct about the Swift 3.0.1 change. However, I think your statements may be a little jumbled as mine were indeed in the wrong spot according to the part 3 finished sample. The handleMatches() function should look as follows:
func handleMatches() {
let chains = level.removeMatches()
if chains.count == 0 {
beginNextTurn()
return
}
scene.animateMatchedCookies(for: chains) {
let columns = self.level.fillHoles()
self.scene.animateFallingCookiesFor(columns: columns) {
let columns = self.level.topUpCookies()
self.scene.animateNewCookies(columns) {
self.view.isUserInteractionEnabled = true
}
}
}
}
Happy Coding!
Hi @badluckbryce,
I think youâre right.
Thanks a lot!
@badluckbryce,
I tried your changes but i still get the error messagesâŠ
What am I doing wrong?
i have my code now like this:
func handleSwipe(_ swap: Swap) {
view.isUserInteractionEnabled = false
if level.isPossibleSwap(swap) {
level.performSwap(swap: swap)
scene.animate(swap){
self.handleMatches()
}
} else {
scene.animateInvalidSwap(swap) {
self.view.isUserInteractionEnabled = true
}
}
}
Now i donât have the error, but the game does not work well. 'Cause if I can make an match of 3, he thinks it isnât a match. And sometimes when the new cookies are falling down he doesnât check if there is a match of 3. Does anyone have this? Or does anyone know how to solve this?
To fix the original error, all I did was change the call of scene.animate(swap) to:
scene.animate(swap, completion: {
self.handleMatches()
self.view.isUserInteractionEnabled = true
})
This is just a different closure syntax that avoids the error and makes the game work as intended.
Hi @mfaarkrog,
I am running into an issue with the final version of the game. When performing a swap of two cookies, if the user were to swipe on the screen while the two cookies are in the middle of their swap animation, often the cookies will perform another swap and have their new position be where the cookie they are swapping with was in the middle of their animation, i.e. off the grid that we have effectively created. I was curious if you ran into this issue/found a way to resolve it. Thanks.
David
This tutorial is more than six months old so questions regarding it are no longer supported for the moment. We will update it as soon as possible. Thank you! :]