无法在 iOS9 中暂停 SKEmitterNode [英] Unable to pause SKEmitterNode in iOS9
问题描述
我尝试了几种解决方法,但仍然无法暂停 iOS9
上的现有粒子.我正在使用以下技术来暂停场景:
- 使用
self.paused = YES;
暂停场景 - 设置自定义
globalPause = YES;
变量来控制update:
方法的执行(因为update:
在场景暂停时仍然运行).
重点是我不会暂停视图,而是暂停场景.由于
谁有合理的解释?到目前为止,我已经尝试显式暂停发射器:
emitterNode.paused = YES;
它不起作用,实际上这应该在场景暂停时自动完成(将发射器添加到场景中).尝试的另一件事是设置 emitter.particleSpeed = 0;
以及 emitter.particleSpeedRange = 0;
和 emitter.particleBirthRate = 0;
但这不会影响已经存在的粒子(这是有道理的).
就是这样.不确定这是否是一个错误,但我的想法已经用完了......
暂停场景:
currentScene.speed = 0currentScene.paused = true
取消暂停场景
currentScene.speed = Variables.gameSpeedcurrentScene.paused = false
这对你有用吗?
PS:你正在开发哪个 iOS 版本?我已经阅读了有关那些发射器的 iOS9.1 问题,似乎在 9.3 中得到了纠正.
I've tried few workarounds, but still I can't pause existing particles on iOS9
. I am using following technique to pause the scene:
- pause the scene with
self.paused = YES;
- set custom
globalPause = YES;
variable to controlupdate:
method execution (becauseupdate:
still runs while scene is paused).
The point is that I don't pause the view, but rather the scene. I don't pause the view, because of this.
Here is the code which can reproduce this issue on iOS9
:
#import "GameScene.h"
@interface GameScene ()
@property (nonatomic, strong)SKEmitterNode *emitter;
@end
@implementation GameScene
-(void)didMoveToView:(SKView *)view {
[self addChild:[self getSpaceDustEmitter]];
}
//No need for this method though :)
-(SKEmitterNode*)getSpaceDustEmitter{
self.emitter = [NSKeyedUnarchiver unarchiveObjectWithFile:[[NSBundle mainBundle] pathForResource:@"spacedust" ofType:@"sks"]];
self.emitter .name = @"emitter_spacedust";
self.emitter .position = CGPointMake(CGRectGetMidX(self.frame),self.frame.size.height);
return self.emitter ;
}
@end
So, very simple example which works on iOS8
and not working as expected on iOS9
. What happens is that even if everything looks that is paused, its not. Existing particles after unpausing move to the point where they should be if the scene was not paused. Also, it looks like that particles keep spawning too, which can produce noticeable lag when unpausing if pause was long...
Here is a screenshot from particle editor:
Anybody have some reasonable explanation ? So far I've tried to explicitly pause the emitter:
emitterNode.paused = YES;
It didn't worked, and actually this should be done automatically when scene is paused (emitter is added to the scene). Another thing which is tried is to set emitter.particleSpeed = 0;
as well as emitter.particleSpeedRange = 0;
and emitter.particleBirthRate = 0;
but this doesn't affect on already existing particles (which make sense).
And thats it. Not sure if this is a bug, but I am run out of ideas...
To pause the scene:
currentScene.speed = 0
currentScene.paused = true
To unpause the scene
currentScene.speed = Variables.gameSpeed
currentScene.paused = false
Does that work for you?
PS: What iOS version are you working on? I've read about problems with iOS9.1, which seems to be corrected in 9.3, about those emitters.
这篇关于无法在 iOS9 中暂停 SKEmitterNode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!