【发布时间】:2018-02-11 07:32:35
【问题描述】:
我正在制作一个游戏,其中一个 SKSpriteNode 需要接触另一个 SKSpriteNode 才能击败对手。
func intersects(node: SKSpriteNode) -> Bool {
if ball.intersects(ygB) == true{
ylicount = ylicount - 1
yourlivescount.text = "\(ylicount)"
if ylicount == 0{
self.view!.window!.rootViewController!.performSegue(withIdentifier: "GameOverViewController", sender: self)
}
}else if ball.intersects(egB) == true{
elicount = elicount - 1;
enemylivescount.text = "\(elicount)"
if elicount == 0{
levelcount += 1
lccalc += 1
ball.physicsBody?.restitution = (ball.physicsBody?.restitution)! - 0.000065416191
ep.run(SKAction.moveTo(x: ball.position.x, duration: 0.5 - (lccalc * 0.00001916151134)))
elicount += 3
ball.position.x = 0
ball.position.y = 0
}
}
本质上,有两个目标:yg 和 eg。 ygB 是 yg 周围不可见的 SKNode,egB 与 eg 相同。如果球与 ygB 或 egB 相交,代码应该会采取相应的行动
我做错了什么?
【问题讨论】:
标签: swift nodes skspritenode intersect