Heres the code hope you can help me thanks.
It comes up as Thread 1: EXC_BAD_INSTRUCTION (code=EXC_l386_INVOP,subcode = EXC_1386_INVOP,subcode=0*0)
The line that it is on is: let overlayScene = SKScene(fileNamed: fileName)!
import SpriteKit
import CoreMotion
class GameScene: SKScene {
let manager = CMMotionManager()
//MARK: - Properties
var bgNode = SKNode()
var fgNode = SKNode()
var background: SKNode!
var backHeight: CGFloat = 0.0
var player: SKSpriteNode!
var platform5Across: SKSpriteNode!
var coinArrow: SKSpriteNode!
var lastItemPosition = CGPointZero
var lastItemHeight: CGFloat = 0.0
var levelY: CGFloat = 0.0
override func didMoveToView(view: SKView) {
setupNodes()
manager.startAccelerometerUpdates()
manager.accelerometerUpdateInterval = 0.1
manager.startAccelerometerUpdatesToQueue(NSOperationQueue.mainQueue()){
(data, error) in
self.physicsWorld.gravity = CGVectorMake(CGFloat((data?.acceleration.x)!) * 10, CGFloat((data?.acceleration.y)!) * 10) }
}
func setupNodes(){
let worldNode = childNodeWithName("World")!
bgNode = worldNode.childNodeWithName("Background")!
background = bgNode.childNodeWithName("Overlay")!.copy()
as! SKNode
backHeight = background.calculateAccumulatedFrame().height
fgNode = worldNode.childNodeWithName("Foreground")!
fgNode.childNodeWithName("Bomb")?.runAction(SKAction.hide())
platform5Across = loadOverlayNode("Platform5Across")
coinArrow = loadOverlayNode("CoinArrow") }
// MARK: Platform/Coin overlay nodes.
func loadOverlayNode(fileName: String) -> SKSpriteNode {
l**et overlayScene = SKScene(fileNamed: fileName)!**
let contentTemplateNode =
overlayScene.childNodeWithName("Overlay")
return contentTemplateNode as! SKSpriteNode }
func createOverlayNode(nodeType: SKSpriteNode, flipX: Bool) {
let platform = nodeType.copy() as! SKSpriteNode
lastItemPosition.y = lastItemPosition.y +
(lastItemHeight + (platform.size.height / 2.0))
lastItemHeight = platform.size.height / 2.0
platform.position = lastItemPosition
if flipX == true {
platform.xScale = -1.0
}
fgNode.addChild(platform)
}
func createBackgroundNode() {
let backNode = background.copy() as! SKNode
backNode.position = CGPoint(x: 0.0, y: levelY)
bgNode.addChild(backNode)
levelY += backHeight
func setupLevel() {
//Place initial platform
let initialPlatform = platform5Across.copy() as! SKSpriteNode
var itemPosition = player.position
itemPosition.y = player.position.y -
((player.size.height * 0.5) +
(initialPlatform.size.height * 0.320))
initialPlatform.position = itemPosition
fgNode.addChild(initialPlatform)
lastItemPosition = itemPosition
lastItemHeight = initialPlatform.size.height / 2.0
}
}
}