且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

多次检测到碰撞。

更新时间:2023-02-02 10:34:32

虽然还不是很完美,但我还是找到了答案……我的鸟的身体从

I sort of found the answer to this, though it is not perfect... the physicsBody of my bird was changed from

bird = SKPhysicsBody(texture: bird.texture!, size: CGSize(width: bird.size.width, height: bird.size.height))

 let path = CGMutablePath()
    path.addLines(between: [CGPoint(x: -8, y: -28),
                  CGPoint(x: -30, y: 9), CGPoint(x:-11, y: 14), CGPoint(x: -10, y: 27),
                  CGPoint(x: 26, y: 22), CGPoint(x: 32, y: 20),
                  CGPoint(x: 30, y: 14), CGPoint(x: 23, y: -17), CGPoint(x: 15, y: -31)])
    path.closeSubpath()
    bird.physicsBody = SKPhysicsBody(polygonFrom: path)

我创建的新路径是一条简单得多的路径,基本上具有正方形的正面。因此,形状不可能与我的scoreNode发生两次碰撞。这可能不是很清楚的说明,但是如果有人遇到相同的问题,请不要犹豫!这是制作我的飞鸟应用程序的最大挫折!

The new path I created was a much simpler path which basically had a square front. So it made it impossible for the shape to collide with my scoreNode twice. This may not be very clear instructions but if anyone has the same problems don't hesitate to ask! This has been the biggest set back of making my flappy bird app!