简体   繁体   中英

Why won't this image fit to the screen size?

I posted a question yesterday trying to figure out why the sprite kit was distorting my image. I was given a great answer, however it was only semi-helpful for my problem.

I was told to name the image name@2x.png then to only call name in the code and that it would solve the problem. Unfortunately this didn't work.

This is what I was getting before trying that:

在此处输入图片说明

Code:

SKSpriteNode *background = [SKSpriteNode spriteNodeWithTexture:[SKTexture textureWithImageNamed:@"bgs.png"] size:CGSizeMake(568,320)];
background.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));

[self addChild:background];

But after changing the images name to bgs@2x.png, and only writing bgs in the code, this is what I got:

在此处输入图片说明

Code:

    SKSpriteNode *background = [SKSpriteNode spriteNodeWithTexture:[SKTexture textureWithImageNamed:@"bgs"]];
    background.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));

    [self addChild:background];

Which is closer to what I want but obviously still not right.

Why won't it just fit to screen? What is going on that it either stretches the image too much or compresses the image too little?

IMAGE DIMENSIONS: 568 x 320 GAME ORIENTATION: Landscape

Your @2x image size must be 1136x640 to fill the whole screen. Just renaming it won't do the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM