Я получаю очень странный сбой при попытке изменить положение SKSpriteNode. Этот сбой происходит в iOS8, а не в iOS9.Ошибка EXC_BAD_ACESS в SpriteKit на 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()
}
Катастрофа происходит, когда я пытаюсь установить позицию (fewerColorsPowerupIcon.position
), и это сообщение аварии:
Тема 1: EXC_BAD_ACCESS (код = EXC_I386_GPFLT)
Это аварии все еще случается, если я положил код .removeFromParent()
после того, как я установил положение узла.
вы пробовали просто установив объект на ноль вместо удаления из родителей ? –
Как объявляется меньшее значениеColorsPowerupIcon? –
@LouFranco объект объявлен var lesserColorsPowerupIcon: SKSpriteNode! – Onglo