You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When importing this code for use in a Swift based SpriteKit (iOS8) project, I would consistently get a crash when trying to run a second animation on top of the queue. After hours of stepping through code, the issue stemmed from assigning _previousAnimation = _currentAnimation in -(void)stopAnimationAndPlayNextInQueue:(BOOL)queueNext which then somehow corrupted the queuedAnimation property.
My solution in the end was to change the property declaration in SGG_Spine.h to read @property (nonatomic, strong) NSString* queuedAnimation. I didn't want to make a pull request because I wasn't 100% sure what the real issue was (or if it would break anything on other target platforms), but I figured I'd leave this here for others to look into, or to save anyone else some time.
The code I was using for those interested:
class GameScene: SKScene {
var boy: SGG_Spine
override init(size: CGSize) {
boy = SGG_Spine.node()
super.init(size: size)
}
required init(coder aDecoder: NSCoder) {
boy = SGG_Spine.node()
super.init(coder: aDecoder)
}
override func didMoveToView(view: SKView) {
/* Setup your scene here */
boy.skeletonFromFileNamed("spineboy", andAtlasNamed: "spineboy", andUseSkinNamed: nil)
boy.position = CGPointMake(frame.width/2, frame.height/2)
boy.queuedAnimation = "walk"
boy.queueIntro = 0.1
boy.runAnimation("walk", andCount: 0, withIntroPeriodOf: 0.1, andUseQueue: true)
boy.zPosition = 0
addChild(boy)
}
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
/* Called when a touch begins */
boy.runAnimation("jump", andCount: 0, withIntroPeriodOf: 0.1, andUseQueue: false)
}
override func update(currentTime: CFTimeInterval) {
/* Called before each frame is rendered */
boy.activateAnimations()
}
}
When the jump animation completed in touchesBegan() it would crash from trying to access corrupted memory (queuedAnimation).
The text was updated successfully, but these errors were encountered:
I haven't played with Swift yet, but my initial thought is that there shouldn't be any issues with implementing this change. The only reason I used "assign" was habit formed as I followed tutorials. I looked up what it was actually doing once, but forgot the details. However, I can't forsee there being any issue with making it strong. I'll look into it a bit when I think of it and have time.
When importing this code for use in a Swift based SpriteKit (iOS8) project, I would consistently get a crash when trying to run a second animation on top of the queue. After hours of stepping through code, the issue stemmed from assigning
_previousAnimation = _currentAnimation
in-(void)stopAnimationAndPlayNextInQueue:(BOOL)queueNext
which then somehow corrupted thequeuedAnimation
property.My solution in the end was to change the property declaration in
SGG_Spine.h
to read@property (nonatomic, strong) NSString* queuedAnimation
. I didn't want to make a pull request because I wasn't 100% sure what the real issue was (or if it would break anything on other target platforms), but I figured I'd leave this here for others to look into, or to save anyone else some time.The code I was using for those interested:
When the jump animation completed in
touchesBegan()
it would crash from trying to access corrupted memory (queuedAnimation).The text was updated successfully, but these errors were encountered: