Ich bekomme einen sehr seltsamen Absturz beim Versuch, die Position eines SKSpriteNode zu ändern. Dieser Absturz passiert in iOS8 und nicht in iOS9.EXC_BAD_ACESS Absturz in SpriteKit auf iOS8
// if the powerup is full, spawn the icon on screen
if orangeBallsCollected == numberOfBallsRequiredToActivatePowerup {
// add the powerup icon to the array of powerupiconsonscreen
powerupIconsOnScreen.append(fewerColorsPowerupIcon)
// set the lighting mask of the powerup icon so that we know what positon it is onscreen for alter
fewerColorsPowerupIcon.lightingBitMask = UInt32(powerupIconsOnScreen.count - 1)
// remove the ball from its current parent
fewerColorsPowerupIcon.removeFromParent()
print(fewerColorsPowerupIcon, fewerColorsPowerupIcon.parent, fewerColorsPowerupIcon.physicsBody, fewerColorsPowerupIcon.superclass)
// place the ball of the screen so that we can bring it on later
fewerColorsPowerupIcon.position = CGPointMake((width * -0.1) , (height * -0.1))
// set the size of the icon
fewerColorsPowerupIcon.xScale = scaleFactor
fewerColorsPowerupIcon.yScale = scaleFactor
// add it the scene
self.addChild(fewerColorsPowerupIcon)
// animate it moving down to the first avaliable position
let animation = SKAction.moveTo(CGPoint(x: width * 0.1, y: height * 0.1), duration: 0.5)
// run the animation!
fewerColorsPowerupIcon.runAction(animation)
// activate the poweurp
activateFewerColors()
}
Der Absturz passiert, wenn ich versuche, die Position zu setzen (fewerColorsPowerupIcon.position
) und das ist der Crash-Nachricht:
Gewinde 1: EXC_BAD_ACCESS (code = EXC_I386_GPFLT)
Dieser Absturz passiert immer noch, wenn ich das .removeFromParent()
Stück Code, nachdem ich die Position des Knotens gesetzt habe.
haben Sie gerade versucht, das Objekt zu Null Einstellung stattdessen entfernen von Eltern ? –
Wie wird wenigerColorsPowerupIcon deklariert? –
@LouFranco das Objekt wird deklariert var lessColorsPowerupIcon: SKSpriteNode! – Onglo