Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios SpriteKit背景不适合iPhone 6 plus的屏幕_Ios_Sprite Kit_Iphone 6 Plus - Fatal编程技术网

Ios SpriteKit背景不适合iPhone 6 plus的屏幕

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];

我使用缩放模式填充加载背景大小为640x1136的场景,如下所示:

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)

它会将锚点设置为节点的中心,并将节点定位在场景的中心。

除非您另有指定,否则“精灵套件”视图不会占据整个屏幕