在所有屏幕尺寸Swift上正确缩放节点边界

时间:2016-02-29 19:19:49

标签: ios iphone swift ipad

]

我正在尝试将两个SKSpriteNodes设置为边界(顶部/底部)并将它们锚定到屏幕上的特定坐标,这样当我从iPhone 5切换到6+时,边界仍然处于相同的位置。我似乎在使节点图像正确显示时遇到一些麻烦。它们要么放大,要么在屏幕上不存在。

这是我到目前为止的代码:

select a.id, listagg(b.value, ',') within group (order by b.value)
from a left join
     b
     on a.name = b.name
where a.id = 12345
group by a.id;

self.addChild(topRectangle)

let size = CGRect(x: 100, y: 98, width:200, height:271)

bottomRectangle = SKSpriteNode(imageNamed: "bottomRectangle")

bottomRectangle.anchorPoint = CGPointMake(0.5, 0.3) // bottom center anchor points
bottomRectangle = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame))
bottomRectangle.zPosition = 3
bottomRectangle.size.height = self.size.height
bottomRectangle.size.width = self.size.width
bottomRectangle.position = CGPoint(x: 0.5, y: 0.3)
bottomRectangle.physicsBody = SKPhysicsBody(edgeLoopFromRect: size)





self.addChild(bottomRectangle)

topRectangle = SKSpriteNode(imageNamed: "topRectangle")

topRectangle.anchorPoint = CGPoint(x:0.5,y:0.8) // top center anchor points
topRectangle.physicsBody = SKPhysicsBody(edgeLoopFromRect: size)
topRectangle.zPosition = 4
topRectangle.size.height = self.size.height
topRectangle.size.width = self.size.width
topRectangle.position = CGPoint(x: 0.5, y: 0.8)

0 个答案:

没有答案