2
在GameplayKit中,我想遵守协议GKAgentDelegate,因此使用代理方法func agentDidUpdate(agent: GKAgent)
。GKAgentDelegate的协议方法在Swift中不正确?
问题是,在这种方法中,参数代理被声明为GKAgent,不GKAgent2D,让我无法访问agent.position
,因为位置属性是GKAgent2D,不GKAgent ...
然而,在目标-C API,代理被声明为GKAgent2D。
请帮忙。
This Works,thank you。但我仍然不明白他们为什么在Swift中将代理声明为GKAgent,但是Objective-C中的GKAgent2D .. –
哦,是的,这是'GKAgent',我的不好。演示代码在执行时将其更改为' - (void)agentDidUpdate:(nonnull GKAgent2D *)agent'。 –