DEV Community

Cover image for #100DaysOfSwift: Project 11
KeeyboardKeda
KeeyboardKeda

Posted on

#100DaysOfSwift: Project 11

Hello,

I've decided that I wanted to recap what I've learned from the projects that I am doing with #100DaysOfSwift as a way to help me remember. I will start with Project 11 which was a game we created in SpriteKit called Pachinko.

Project 11 Recap:

A SKScene is the parent of a node and nodes are organized in a tree-like structure to the parent. A frame is a rectangle that contains the contents of the node. Anything in the didMove() method displays on the screen as soon as it loads. The body of this method holds the code for the background image, the edit labels, the slots, the score, and the bouncers.

The touchesBegan ()method detects whenever the user touches the screen. The body of this method holds the feature of the user being able to toggle between "Edit" and "Done". In the editing mode the user can add blocks of different lengths to create obstacles when they try to drop a ball into the slots. This method also holds the code for creating a ball when the screen is touched and allowing the ball to fall.

Key Takeaways:

  1. Anchor points determine what coordinates are used to position children. The bottom left corner of the screen is the considered Y:0.

  2. SKSpriteNode is used to to grab images from Assets.xcassets.

  3. Set means a set that stores an object representing the location, size, movement, and force of touch occurring on the screen. I.e the user touches the screen and the ball appears and its at a certain location, a certain size, etc.

  4. physicsbody = SKPhysicsBody(edgeLoopFrom: frame) creates an impassible boundary around the frame.

  5. collisionBitMask determines what object a node bounces off and contactTestBitMask determines which collisions are reported.

Discussion (0)