我正在使用iOS SpriteKit构建游戏。我有一个常规UIViewController
“选择器”,它可以分成第二个加载SKScene的VC。 SKScene
加载SKSprites
并在屏幕上通过SKAction
移动它们。当我第一轮比赛时,它很有效。
完成游戏后,我们返回Chooser
设置下一轮。我用相同的SKScene
重新加载相同的VC。这次创建了Sprite,但SKAction
没有运行。我添加了一堆日志语句来跟踪它。
以下是SKAction
的代码:
NSInteger startZone = [TPMathUtilities randomOffscreenStartZone];
CGPoint startPointONE = [TPMathUtilities OFFScreenPointFinder:startZone];
NSInteger finishZone = [TPMathUtilities finishZoneFinder:startZone];
CGPoint finishPointONE = [TPMathUtilities OFFScreenPointFinder:finishZone];
NSLog(@"startPointONE = %f %f finishPointONE = %f %f", startPointONE.x,startPointONE.y,finishPointONE.x,finishPointONE.y);
newTap.position = startPointONE;
CGFloat distanceToOffScreenPt = [TPMathUtilities distanceBetweenTwoPoints:startPointONE toPoint:finishPointONE];
CGFloat movementDuration = distanceToOffScreenPt/[[TPGameData data] tapBaseGeneratorVelocity];
NSLog(@"movementDuration = %f", movementDuration);
newTap runAction:[SKAction sequence:@[[SKAction runBlock:^{NSLog(@"starting TAP ACTIONS ");}],
[SKAction moveTo:finishPointONE duration:movementDuration],
[SKAction removeFromParent]]]];
这是第一轮的日志,你可以看到“开始TAP ACTIONS”
UPDATE variables: localGenMult= 0.800000 tapBaseGen= 0.800000 gameInterval= 0.511158
startPointONE = -50.000000 740.000000 finishPointONE = 913.000000 -50.000000
movementDuration = 4.529381
UPDATE after Sprite Added
starting TAP ACTIONS
UPDATE variables: localGenMult= 0.800000 tapBaseGen= 0.800000 gameInterval= 0.512250
startPointONE = 1064.000000 158.000000 finishPointONE = 521.000000 808.000000
movementDuration = 3.079871
UPDATE after Sprite Added
starting TAP ACTIONS
UPDATE variables: localGenMult= 0.800000 tapBaseGen= 0.800000 gameInterval= 0.561383
startPointONE = 1064.000000 451.000000 finishPointONE = -50.000000 755.000000
movementDuration = 4.199035
UPDATE after Sprite Added
starting TAP ACTIONS
UPDATE variables: localGenMult= 0.800000 tapBaseGen= 0.800000 gameInterval= 0.507709
startPointONE = 921.000000 808.000000 finishPointONE = -50.000000 110.000000
movementDuration = 4.348527
UPDATE after Sprite Added
starting TAP ACTIONS
这是第二轮没有SKAction:
UPDATE variables: localGenMult= 0.800000 tapBaseGen= 0.800000 gameInterval= 0.813655
startPointONE = 1064.000000 440.000000 finishPointONE = -50.000000 7.000000
movementDuration = 4.346155
UPDATE after Sprite Added
UPDATE variables: localGenMult= 0.800000 tapBaseGen= 0.800000 gameInterval= 0.813989
startPointONE = 437.000000 -50.000000 finishPointONE = 652.000000 808.000000
movementDuration = 3.216464
UPDATE after Sprite Added
UPDATE variables: localGenMult= 0.800000 tapBaseGen= 0.800000 gameInterval= 0.806389
startPointONE = 992.000000 -50.000000 finishPointONE = 856.000000 808.000000
movementDuration = 3.158952
UPDATE after Sprite Added
UPDATE variables: localGenMult= 0.800000 tapBaseGen= 0.800000 gameInterval= 0.811594
startPointONE = -50.000000 146.000000 finishPointONE = 1064.000000 746.000000
movementDuration = 4.601108
UPDATE after Sprite Added
我创建SKScene
的代码保持不变,上面的代码不会更改。有没有猜到为什么动作在第二轮Sprite上没有激活?