Quick Position SKSpiteNode iPhone V iPad

I placed the node in the upper left corner of the view in my application using the following code:

health = SKSpriteNode(color: .green, size: CGSize(width: progressValue, height: 50))
health.position = CGPoint(x: -self.frame.width / 2, y: self.frame.height / 2)

This is correctly positioned in all iPhone simulators from 5 to 7 Plus.

However, it does not appear in any iPad simulator. I set the position to midX and midY, and it just didn't look with the code above, which works fine for all iPhones.

What am I missing?

Is there any other way to position nodes in the view for iPhone v iPad instead of using multiple view?

+4
source share
1 answer

SOLVE:

, scaleMode .aspectFill, iPhones, iPads.

.resizeFill , , .

if UIDevice.current.userInterfaceIdiom == .pad {

                scene.scaleMode = .resizeFill

            }else{

                scene.scaleMode = .aspectFill


            }
+1

Source: https://habr.com/ru/post/1674436/


All Articles