gpt4 book ai didi

ios - SpriteKit : Could not find an overload for 'runAction' that accepts the supplied arguments

转载 作者:行者123 更新时间:2023-11-28 09:11:21 26 4
gpt4 key购买 nike

代码生成以下错误:

如果我们清空 runBlock,它可以正常编译,所以它表明 runBlock 有问题。错误太隐蔽,我们无法找出问题所在。

有什么想法吗?

        func didBeginContact(contact: SKPhysicsContact!) {
let nodeB = contact.bodyB.node?

nodeB?.runAction(
SKAction.sequence([
SKAction.runBlock {
nodeB?.physicsBody?.applyForce( CGVectorMake(0, -2.0) )
},
SKAction.waitForDuration(0.2)
])
)
}

最佳答案

你应该把 applyForce 放在它自己的函数中,然后在你的 runBlock 中调用它:

func didBeginContact(contact: SKPhysicsContact!) {
let nodeB = contact.bodyB.node?

nodeB?.runAction(
SKAction.sequence([
SKAction.runBlock {
self.applyTheForce(nodeB!)
},
SKAction.waitForDuration(0.2)
])
)
}

func applyTheForce(node:SKNode){
node.physicsBody?.applyForce(CGVectorMake(0, 0))
}

关于ios - SpriteKit : Could not find an overload for 'runAction' that accepts the supplied arguments,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29243769/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com