Last active
January 28, 2016 20:08
-
-
Save lucasprag/df177169866589d7b2f8 to your computer and use it in GitHub Desktop.
Creating a floor in the GameScene
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SpriteKit | |
class GameScene: SKScene { | |
let floor = SKSpriteNode(imageNamed: "blue") | |
override func didMoveToView(view: SKView) { | |
setupFloor() | |
} | |
func setupFloor() { | |
// we define a name to our node | |
floor.name = "floor" | |
// the size is represented by the CGSize | |
// note that we are getting the size (CGSize) from the scene | |
// and it will fill 1/3 of the screen | |
floor.size = CGSize(width: self.size.width * 3, height: self.size.height/3) | |
// we are putting the floor in the base of our screen | |
floor.position = CGPoint(x: CGRectGetMinX(self.frame) + (floor.size.width / 2), | |
y: CGRectGetMinY(self.frame) + (floor.size.height/2)) | |
// this add the floor to the scene in order to appear in the screen | |
addChild(floor) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment