What is SKSpinLockSync in Sprite Kit and how do I fix it

前端 未结 7 846
忘了有多久
忘了有多久 2021-01-05 10:43

I am receiving a bug report with the following stack trace and I have no idea what the problem is. I\'ve seen suggestions that this could be caused by having an emitter\'s

7条回答
  •  清酒与你
    2021-01-05 11:16

    If using SKEmitterNode and create more than 1 at the same time (close around the same time), my game still crashed. I had to manually preload (create and add emitter to scene), by then I was able to prevent the crashing I had to let the particle effect to be created and added to the scene and let it run its action. I then set the particle alpha to 0, to hide it. By then I was By Disappointment, I preloaded everything.

    Using SKEmitterNode and getEmitter method above, I still getting crashes when I create more than 1 emitter around the same time. I solve this by creating one of the particle on the start, add it to the scene, and set its alpha to 0. This is a jacky way and it blows, but it works and doesn't crash.

    Example:

    @implementation MyGameScene
    
    - (instancetype)initWithSize:(CGSize)size
    {
        if(self = [super initWithSize:size]){
            HitEmitter *emitter = [HitEmitter particle]; // class method use getEmitter method
            [self addChild:emitter];
            [emitter setName:@"temp"];
            [emitter setAlpha:0];
    
            // add a second timer to remove it.
            [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(removeEmitter) userInfo:nil repeats:NO];
        } return self;
    }
    

提交回复
热议问题