gpt4 book ai didi

ios - 为什么我的顶部和底部物理主体没有针对 iPad 调整大小?

转载 作者:行者123 更新时间:2023-11-30 14:13:04 26 4
gpt4 key购买 nike

我的屏幕底部和顶部都有一个物理主体。它非常适合我的 iPhone,但当我使用 iPad 模拟器时,它距离屏幕顶部和屏幕底部几英寸。由于某种原因,它不适合 iPad 屏幕的边缘。有人可以帮我弄这个吗?谢谢!这是我使用的代码:

let wall1 = SKSpriteNode(color: SKColor.clearColor(), size: CGSize(width: 2000, height: 5))
let wall2 = SKSpriteNode(color: SKColor.clearColor(), size: CGSize(width: 2000, height: 5))


func wall() {


//top wall border
wall1.position = CGPointMake(self.frame.width / 2, self.size.height / 1.1)
wall1.physicsBody = SKPhysicsBody(rectangleOfSize: wall1.size)
wall1.physicsBody!.dynamic = false
wall1.physicsBody!.categoryBitMask = SideBlockCategory
wall1.physicsBody!.restitution = 0
wall1.physicsBody?.contactTestBitMask = HeroCategory
wall1.physicsBody?.collisionBitMask = 0
wall1.physicsBody?.usesPreciseCollisionDetection = true


//bottom wall border
wall2.position = CGPointMake(self.frame.width / 2, self.size.height / 8.0)
wall2.physicsBody = SKPhysicsBody(rectangleOfSize: wall2.size)
wall2.physicsBody!.dynamic = false
wall2.physicsBody!.categoryBitMask = SideBlockCategory
wall2.physicsBody!.restitution = 0
wall2.physicsBody?.contactTestBitMask = HeroCategory
wall2.physicsBody?.collisionBitMask = 0
wall2.physicsBody?.usesPreciseCollisionDetection = true


}

最佳答案

试试这个;

//top wall border
wall1.position = CGPointMake(self.frame.width / 2, self.frame.height - 2.5)

//bottom wall border
wall2.position = CGPointMake(self.frame.width / 2, 2.5)

关于ios - 为什么我的顶部和底部物理主体没有针对 iPad 调整大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31530097/

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