添加纹理会导致崩溃...(未捕获的异常'NSInvalidArgumentException')

时间:2016-12-03 18:46:08

标签: sprite-kit xcode8 skspritenode sktexture sceneeditor

所以我正在使用侧卷轴。 每个级别都有一个带有自定义类播放器的Sprite。 虽然确定精灵的纹理是由它的空闲动画设置的,但我在每个级别都应用了一个纹理以供参考。

在每个级别,它似乎工作正常

E.g。这是我的主要玩家猴子精灵的等级2,因为它出现在大多数关卡中。

enter image description here

但是,在两个级别上,对此玩家精灵的任何更改都会导致游戏崩溃。 我被迫将这件事作为一个没有纹理的精灵离开......任何一种变化都会导致游戏崩溃。例如,如果我添加一个新纹理,我会收到以下错误。

E.g。在这里它必须没有纹理或我崩溃。 enter image description here

       *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid size specified: {6, -2.6005233764648423}'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001041a534b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010389e21e objc_exception_throw + 48
    2   CoreFoundation                      0x000000010420e265 +[NSException raise:format:] + 197
    3   SpriteKit                           0x0000000104d5060c -[SKSpriteNode initWithTexture:color:size:] + 204
    4   SideScrolleriOS                     0x00000001030248e5 _TFC15SideScrolleriOS8PlatformcfT7textureGSqCSo9SKTexture_5colorCSo7UIColor4sizeVSC6CGSize_S0_ + 661
    5   SideScrolleriOS                     0x00000001030785e6 _TFC15SideScrolleriOS14MovingPlatformcfT7textureGSqCSo9SKTexture_5colorCSo7UIColor4sizeVSC6CGSize_S0_ + 246
    6   SideScrolleriOS                     0x00000001030786e6 _TToFC15SideScrolleriOS14MovingPlatformcfT7textureGSqCSo9SKTexture_5colorCSo7UIColor4sizeVSC6CGSize_S0_ + 86
    7   SpriteKit                           0x0000000104d5157a -[SKSpriteNode initWithColor:size:] + 25
    8   SideScrolleriOS                     0x0000000103026ac4 _TTOFCSo12SKSpriteNodecfT5colorCSo7UIColor4sizeVSC6CGSize_S_ + 36
    9   SideScrolleriOS                     0x000000010301f440 _TFCSo12SKSpriteNodeCfT5colorCSo7UIColor4sizeVSC6CGSize_S_ + 96
    10  SideScrolleriOS                     0x000000010301e9c6 _TFC15SideScrolleriOS8Platform13setUpPlatformfCS_6PlayerT_ + 2166
    11  SideScrolleriOS                     0x0000000103077609 _TFC15SideScrolleriOS14MovingPlatform13setUpPlatformfCS_6PlayerT_ + 73
    12  SideScrolleriOS                     0x00000001030a9b0e _TFC15SideScrolleriOS9GameScene7didMovefT2toCSo6SKView_T_ + 12430
    13  SideScrolleriOS                     0x00000001030b6aaa _TToFC15SideScrolleriOS9GameScene7didMovefT2toCSo6SKView_T_ + 58
    14  SpriteKit                           0x0000000104d12c57 -[SKScene _didMoveToView:] + 198
    15  SpriteKit                           0x0000000104d3152e -[SKView presentScene:transition:] + 364
    16  SideScrolleriOS                     0x000000010309018d _TFC15SideScrolleriOS4Home8loadGamefT_T_ + 13805
    17  SideScrolleriOS                     0x000000010308cb1f _TFC15SideScrolleriOS4Home13pressedSelectfT_T_ + 4159
    18  SideScrolleriOS                     0x0000000103054cff _TFFC15SideScrolleriOS4Home12touchesBeganFTGVs3SetCSo7UITouch_4withGSqCSo7UIEvent__T_U_FTCSo6SKNodeGSpV10ObjectiveC8ObjCBool__T_ + 1375
    19  SideScrolleriOS                     0x0000000103043774 _TTRXFo_oCSo6SKNodedGSpV10ObjectiveC8ObjCBool___XFdCb_dS_dGSpS1____ + 68
    20  SpriteKit                           0x0000000104d4a946 -[SKNode _processSearchTokens:visited:usingBlock:stopPointer:] + 2729
    21  SpriteKit                           0x0000000104d4a083 -[SKNode _processSearchTokens:visited:usingBlock:stopPointer:] + 486
    22  SpriteKit                           0x0000000104d49d3a -[SKNode _enumerateChildNodesWithName:usingBlock:stopPointer:] + 1127
    23  SpriteKit                           0x0000000104d49612 -[SKNode enumerateChildNodesWithName:usingBlock:] + 58
    24  SideScrolleriOS                     0x0000000103054591 _TFC15SideScrolleriOS4Home12touchesBeganfTGVs3SetCSo7UITouch_4withGSqCSo7UIEvent__T_ + 737
    25  SideScrolleriOS                     0x0000000103054e96 _TToFC15SideScrolleriOS4Home12touchesBeganfTGVs3SetCSo7UITouch_4withGSqCSo7UIEvent__T_ + 102
    26  SpriteKit                           0x0000000104d2f6d6 -[SKView touchesBegan:withEvent:] + 1145
    27  UIKit                               0x0000000104feba21 -[UIWindow _sendTouchesForEvent:] + 2043
    28  UIKit                               0x0000000104fed3cf -[UIWindow sendEvent:] + 4011
    29  UIKit                               0x0000000104f9a63f -[UIApplication sendEvent:] + 371
    30  UIKit                               0x000000010578c71d __dispatchPreprocessedEventFromEventQueue + 3248
    31  UIKit                               0x00000001057853c7 __handleEventQueue + 4879
    32  CoreFoundation                      0x000000010414a311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    33  CoreFoundation                      0x000000010412f59c __CFRunLoopDoSources0 + 556
    34  CoreFoundation                      0x000000010412ea86 __CFRunLoopRun + 918
    35  CoreFoundation                      0x000000010412e494 CFRunLoopRunSpecific + 420
    36  GraphicsServices                    0x0000000108cb4a6f GSEventRunModal + 161
    37  UIKit                               0x0000000104f7c964 UIApplicationMain + 159
    38  SideScrolleriOS                     0x0000000103109ecf main + 111
    39  libdyld.dylib                       0x000000010c7c568d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

我试图通过

解决错误
  1. 复制我的等级2并删除除了猴子精灵和相机(以及它的孩子)之外的所有内容,然后从有问题的等级中粘贴所有内容(除了无纹理的精灵和它的相机)。错误仍然存​​在。
  2. 当我在Xcode 7中开发这个东西时似乎没有发生这种情况,但是切换到Swift 3和Xcode 8导致了一些奇怪的错误。

    我已经尝试过这两个问题级别了。我无法弄清楚。如果我只是让它没有纹理,游戏构建工作正常。 我可以在场景编辑器中添加纹理。 但是,构建崩溃了。

    但是,将精灵纹理化以便编辑参考会很有帮助。有人有什么想法吗?

0 个答案:

没有答案