0

So i'm getting this error that says EXC_BAD_INSTRUCTION and I have no idea why can anyone shed any light on it?? the code in question in bold below. Just so you know this is using SWIFT

**actionArray.addObject(SKAction.moveTo(CGPointMake(position, -alien.size.height), duration: NSTimeInterval(duration)))**

    actionArray.addObject(SKAction.removeFromParent())

    alien.runAction(SKAction.sequence(actionArray))

Here is a longer view of the code for you

alien.position = CGPointMake(position, self.frame.size.height+alien.size.height)

    self.addChild(alien)

    let minDuration = 2
    let maxDuration = 4
    let rangeDuration = maxDuration - minDuration
    let duration = Int(arc4random()) % Int(rangeDuration) + Int(minDuration)

    var actionArray:NSMutableArray = NSMutableArray()


    actionArray.addObject(SKAction.moveTo(CGPointMake(position, -alien.size.height), duration: NSTimeInterval(duration)))

    actionArray.addObject(SKAction.removeFromParent())

    alien.runAction(SKAction.sequence(actionArray))
8
  • How is actionArray defined? Commented Jul 26, 2014 at 17:12
  • It would also help to know how position is defined Commented Jul 26, 2014 at 17:18
  • I have sprite.position = location and i have player.position = CGPointMake(self.frame.size.width/2, player.size.height/2 + 20) Commented Jul 26, 2014 at 17:22
  • But you are using a variable that is just position in the line that is crashing. Commented Jul 26, 2014 at 17:23
  • this is what i have for position let position:CGFloat = CGFloat(arc4random()) % CGFloat(rangeX) + CGFloat(minX) Commented Jul 26, 2014 at 17:28

1 Answer 1

1

Is your Xcode updated to beta 4 ?
Also try going to Window -> Organizer -> select your project -> choose delete next to 'Derived Data'.
I had a weird bug where my app would only run in the simulator, and give me the EXC_BAD_INSTRUCTION error if I used my device. Deleting the Derived Data fixed it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.