-
Notifications
You must be signed in to change notification settings - Fork 0
/
BeanBag.swift
52 lines (32 loc) · 1.22 KB
/
BeanBag.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// BeanBag.swift
// SuperCornHole
//
// Created by Clinton Medbery on 11/1/15.
// Copyright © 2015 Programadores Sans Frontieres. All rights reserved.
//
import Foundation
import SpriteKit
class BeanBag : SKSpriteNode{
init(spriteTextureName: String, xPos: CGFloat, yPos: CGFloat, width: Int, height: Int) {
let imageTexture = SKTexture(imageNamed: spriteTextureName)
let spriteSize = CGSize(width: width, height: height)
super.init(texture: imageTexture, color: SKColor.clearColor(), size: spriteSize)
let body: SKPhysicsBody = SKPhysicsBody(texture: imageTexture, size: spriteSize)
self.physicsBody = body
body.dynamic = true
body.affectedByGravity = false
body.allowsRotation = false
self.position.x = xPos
self.position.y = yPos
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setUpBeanBag() {
}
func throwBag(impulseAmount: CGFloat){
self.physicsBody?.velocity = CGVectorMake(0,0)
self.physicsBody?.velocity = CGVectorMake(0, impulseAmount)
}
}