This commit is contained in:
Yuriy Mayatnikov
2020-06-30 15:20:47 +03:00
parent c8123ca15f
commit 413cad5d3c
21 changed files with 998 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
//
// SnakeBodyPart.swift
// snakegame
//
// Created by Nik Rodionov on 23.06.2020.
// Copyright © 2020 nrodionov. All rights reserved.
//
import SpriteKit
class SnakeBodyPart: SKShapeNode {
init(position: CGPoint) {
super.init()
path = UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: 10, height: 10)).cgPath
fillColor = .green
strokeColor = .green
lineWidth = 5
self.position = position
physicsBody = SKPhysicsBody(circleOfRadius: 10.0, center:CGPoint(x: 5, y: 5))
physicsBody?.isDynamic = true
physicsBody?.categoryBitMask = CollisionCategories.Snake
physicsBody?.contactTestBitMask = CollisionCategories.EdgeBody | CollisionCategories.Apple
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}