0

在 SpriteKit 中,我有一个类型为SKShape节点的球类,并且在该类中是一种更改fillColor节点的方法(只有SKShape节点具有该fillColor属性),并且在我的游戏中,我希望每隔几秒钟发射多个球。然而,我的问题是我也希望他们fillColor每次被击中时都改变。我试过了:

-(void)didBeginContact:(SKPhysicsContact *)contact {
    if ([(SKShapeNode*)contact.bodyA.node.name isEqual:@"ball"]) {
        SKShapeNode* node = (SKShapeNode*)contact.bodyA.node;
        [(Ball*)node ...call function to change fill color];
    }
}

但它只是在接触时崩溃

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SKShapeNode ballHit]: unrecognized selector sent to instance 0x1780ee880'
*** First throw call stack:
(0x18cf4ef50 0x1994581fc 0x18cf53c04 0x18cf51930 0x18ce715dc 0x1000f6718 0x194cf0f1c 0x194cef26c 0x18fdcce08 0x18fddffc8 0x18fdddab0 0x18fddb794 0x18fdfaa90 0x1002a3c80 0x18fb54cbc 0x18fb54ac8 0x18de4fe74 0x18cf008e0 0x18cf0ee90 0x18cf0edf0 0x18cf0d014 0x18ce4dc20 0x192b35c0c 0x18ff7efdc 0x1000f4eec 0x199a4baa0)
libc++abi.dylib: terminating with uncaught exception of type NSException
4

0 回答 0