在iOS 8中测试我的应用时,我遇到了一些严重的渲染问题。我不会浪费文字试图写出易于理解的描述,而只会向您展示一段简短的视频:
这就是它的工作原理。 iOS 7.
这就是它breaks in iOS 8.
的方式您所看到的内容略有细分:放大的瓷砖是在每个瓷砖上单独运行的SKAction。瓦片以alpha为0生成,SKAction将它们逐渐淡入,一次一个。如果我生成alpha为1.0的图块,它们会显示出来,但不会执行任何操作。其他行动也随机不运行。所以至少SKAction似乎存在一些问题。然而,当新的一轮发生时,我无法弄清楚是什么让剩下的场景消失了。根本没有与这些节点或纹理相关的SKActions。
有人知道iOS 8中SpriteKit是否有新的限制或问题?特别是与SKAction相关,但任何可能与此有关的事情都会发生?
编辑:我只是想澄清一下,即使iOS 8的视频是模拟器,我也有一个测试版测试人员在真实的iOS 8设备上报告了这个确切描述的问题。 iOS 7视频是我自己的iOS 7设备的屏幕截图。
编辑:这里有一些与此相关的代码:
-(void)startNewRoundWithGridSize:(CGFloat)newGridSize andWormCount:(NSInteger)wormCount{
gameData.currentWormScore = (int)currentRound;
[gameData checkAchievements];
previousRandomShake = sharedUtilities.currentTime + 10;
[self randomizeShakeType];
if (gameData.isComputer || gameData.isPhone5) {
directionImage.position = wormDirectionPhone5GamePos;
} else if (gameData.isPhone4) {
directionImage.position = wormDirectionPhone4GamePos;
} else if (gameData.isPad) {
directionImage.position = wormDirectionPadGamePos;
}
directionImage.hidden = VISIBLE;
[directionImage setScale:0.33];
roundCounter.hidden = VISIBLE;
timerBar.hidden = VISIBLE;
int additionalTime = [settingsDict[@"subsequentRoundTimerPoints"] integerValue] + 0.5 * timerValue;
if (currentRound == 1) {
timerValue = [settingsDict[@"firstRoundTimerPoints"] integerValue];
} else {
timerValue = additionalTime;
}
if (gameData.godMode) {
timerValue = 600000000;
}
gridSize = newGridSize;
if (gameData.isPhone4 || gameData.isPhone5 || gameData.isComputer) {
tileBaseSize = 80;
} else if (gameData.isPad) {
tileBaseSize = 192;
}
roundCounter.intValue = currentRound;
SKNode* oldWorld = [self childNodeWithName:@"wormWorld"];
if (oldWorld.parent) {
[oldWorld removeFromParent];
}
[startButton disableButton];
[backButton disableButton];
[instructionsButton disableButton];
startButton.hidden = HIDDEN;
backButton.hidden = HIDDEN;
instructionsButton.hidden = HIDDEN;
wormArray = nil;
wormArray = [[NSMutableArray alloc] init];
tilesArray = nil;
tilesArray = [[NSMutableArray alloc] init];
SKSpriteNode* alphaNode = [SKSpriteNode spriteNodeWithColor:[SKColor whiteColor] size:CGSizeMake(self.size.width, self.size.width)];
alphaNode.anchorPoint = CGPointZero;
alphaNode.position = CGPointMake(0, 0);
CGFloat worldYPos = (self.size.height - self.size.width) / 2 ;
SKCropNode* wormWorld = [SKCropNode node];
wormWorld.position = CGPointMake(0, worldYPos);
wormWorld.name = @"wormWorld";
wormWorld.maskNode = alphaNode;
wormWorld.zPosition = zGameLayer;
[self addChild:wormWorld];
SKSpriteNode* wormAreaBackground = [SKSpriteNode spriteNodeWithColor:[SKColor colorWithRed:0 green:0 blue:0 alpha:0.45] size:CGSizeMake(self.size.width, self.size.width)];
wormAreaBackground.anchorPoint = CGPointZero;
wormAreaBackground.name = @"wormAreaBackground";
wormAreaBackground.zPosition = 0;
[wormWorld addChild:wormAreaBackground];
SKNode* wormScaler = [SKNode node];
wormScaler.name = @"wormScaler";
wormScaler.xScale = 4 / gridSize;
wormScaler.yScale = 4 / gridSize;
wormScaler.zPosition = 1;
[wormWorld addChild:wormScaler];
//tiles
CGFloat totalDuration = 1;
CGFloat duration = 0.15;
SKAction* tileScaleIn = [SKAction sequence:@[
[SKAction scaleTo:5 duration:0],
[SKAction scaleXTo:1.0f y:1.0f duration:0.1],
]];
SKAction* tileFadeIn;
if (gameData.debugMode) {
tileFadeIn = [SKAction fadeAlphaTo:0.5f duration:duration];
} else {
tileFadeIn = [SKAction fadeAlphaTo:1.0f duration:duration];
}
SKAction* tileAnimation = [SKAction group:@[
tileScaleIn,
tileFadeIn,
]];
for (int i = 0; i < gridSize; i++) {
int y = i * tileBaseSize + 0.5 * tileBaseSize; //start new row of tiles and set y pos
for (int h = 0; h < gridSize; h++) {
int x = h * tileBaseSize + 0.5 * tileBaseSize; //set x of current tile
SGG_TileNode* tile = [SGG_TileNode node];
if (gameData.debugMode) {
tile.debugMode = YES;
}
tile.position = CGPointMake(x, y);
tile.gridSize = CGSizeMake(gridSize, gridSize);
tile.tileIndex = i * gridSize + h;
tile.name = @"tile";
tile.zPosition = zGameLayer + 15;
tile.alpha = 0.0;
[wormScaler addChild:tile];
[tilesArray addObject:tile];
SKAction* waitABit = [SKAction waitForDuration:((totalDuration - 0.2) / (gridSize * gridSize)) * tile.tileIndex];
SKAction* totalAction = [SKAction sequence:@[
waitABit,
tileAnimation,
]];
[tile runAction:totalAction withKey:@"startingZoom"];
}
}
gameStarting = YES;
}
我知道它相当长。 :(
编辑:好的,经过一些进一步的测试,(在iOS 8和8.1中)我在游戏开始前已经在场景中添加了一个SKAction。它在游戏开始之前工作正常,但一旦启动,动作就会停止。再一次,这只发生在iOS 8+而不是iOS 7.对可以同时运行的SKAction的数量有什么限制吗? SKActions在达到某种内存限制时会停止(包括艺术资产和内存中的其他对象)吗?如果是,为什么它只影响iOS 8+?不,我不会意外地暂停现场。为了绝对肯定,我添加了
self.paused = NO;
要更新方法以确定游戏没有暂停。