Want to build 2D games on , macOS, tvOS, and watchOS? SpriteKit gives you everything you need from rendering sprites to physics simulation. iOS even Everything in a SpriteKit game lives in an instance of the class. This object is the root of what is called the node hierarchy, a collection of nodes with parent-child relationships. For example, you might have an effects node, which is a child of your player node and that player node is child of the root node, the scene. SKScene All of this fancy hierarchy stuff works because every SpriteKit class is inherited from . This class contains the logic for constructing the parent-child relationships of nodes in the scene. SKNode let scene = SKScene()let player = SKSpriteNode(imageNamed: "player")scene.addChild(player) The call places our player node in the scene. As you might have noticed, our player is an , another valuable class that you will use countless times in a game. As the name suggests, pulls a sprite from your asset catalog, in this case one named and creates a node. addChild SKSpriteNode SpriteKit SKSpriteNode "player" Since inherits from , we get a property on our sprite called , which is a (a simple struct that has two properties of its own, and ). The property defaults to the point , which is relative to the of the parent node. Let’s break all this down. SKSpriteNode SKNode position CGPoint x y position (0.0, 0.0) anchorPoint First of all, it is important to note that in SpriteKit on the y-axis is at the bottom-left of the screen, unlike in UIKit or AppKit, where on the y-axis is at the top-left. 0 0 x and y-axes in SpriteKit The scene has an origin point which is determined by its , a percentage of its height and width. Let’s say our scene is as big as our screen, which happens to be 480 pixels in height and 320 pixels in width, and the is . This means that the scene’s origin is at 25% of the width and 75% of the height, in exact terms, and , so the origin is . anchorPoint anchorPoint (0.25, 0.75) 0.25 * 320 = 80 0.75 * 480 = 360 (80, 360) In the example above, we add our player node to the scene without setting the player’s position, so it will be at , relative to the scene’s origin. Therefore on the screen we’ll see the player node at the coordinates . For more practical purposes, let’s set the scene’s to (the default for a scene created with Xcode’s SpriteKit game project). (0, 0) (80, 360) anchorPoint (0.5, 0.5) anchorPoint let scene = SKScene(size: CGSize(width: 320, height: 480))scene.anchorPoint = CGPoint(x: 0.5, y: 0.5)let player = SKSpriteNode(imageNamed: "player")scene.addChild(player) Now when we place our player node, the player will be at on the screen. Then we’ll use what’s called an to move our player from its current position to a new on, for example, 80 pixels to the right and 120 pixels down, taking a total of 2 seconds. (160, 240) SKAction let moveAction = SKAction.move(byX: 80, y: -120, duration: 2)player.run(moveAction) Calling the method on our player node with the move action will tell SpriteKit to update the node’s position over the course of 2 seconds, animating it across the screen. run Credit to Kenney for sprite — https://kenney.nl/assets Now you’ve got a good starting point to making a SpriteKit game all in less than 10 lines of code! Speaking of SpriteKit games, check out my game, Blueshift, on the App Store! _Read reviews, compare customer ratings, see screenshots, and learn more about Blueshift Tiles. Download Blueshift Tiles…_appsto.re Blueshift Tiles on the App Store