Ios SpriteKit背景不适合iPhone 6 plus的屏幕
我使用缩放模式填充加载背景大小为640x1136的场景,如下所示:Ios SpriteKit背景不适合iPhone 6 plus的屏幕,ios,sprite-kit,iphone-6-plus,Ios,Sprite Kit,Iphone 6 Plus,我使用缩放模式填充加载背景大小为640x1136的场景,如下所示: SKView * skView = (SKView *)self.view; skView.ignoresSiblingOrder = YES; MainMenu *scene = [MainMenu sceneWithSize: self.view.bounds.size]; scene.scaleMode = SKSceneScaleModeAspectFill; [skView presentScene:scene];
SKView * skView = (SKView *)self.view;
skView.ignoresSiblingOrder = YES;
MainMenu *scene = [MainMenu sceneWithSize: self.view.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
[skView presentScene:scene];
然后我在屏幕内加载背景:
SKSpriteNode *menuBg = [SKSpriteNode spriteNodeWithImageNamed:@"mainBg"];
menuBg.anchorPoint = CGPointZero;
menuBg.position = CGPointZero;
[self addChild:menuBg];
我希望backgound能填满屏幕,但是它不会调整大小来填满屏幕。我只拿着一张@2x背景图片-我做错了什么 您没有将节点定位在场景的中心,因此无法使用Aspect Fill scalemode对其进行正确缩放 请尝试以下方法:
menuBg.anchorPoint = CGPointMake(0.5, 0.5);
menuBg.position = CGPointMake(self.size.width/2, self.size.height/2)
它会将锚点设置为节点的中心,并将节点定位在场景的中心。除非您另有指定,否则“精灵套件”视图不会占据整个屏幕