xcodesprite-kitskspritenodeskphysicsbody

SpriteKit SKPhysicsContact Issue


In a game I'm making I am having an issue where when my player & coin come into contact with one another they collide then the coin rolls right off & then deletes itself from the game scene. The way I want it to work is when the coin collides with my player, it would count as 1 point & to have the coin delete itself upon them making contact. This is the code I have so far


Solution

  • It is very important to keep your code aligned, and to keep an eye on capitalization since since swift is case sensitive.

    The errors in this code were player missing a name, a missing brace at the end of touchesMoved, and the didBegin being all lowercase.

    Hopefully this will be a lesson in code management.