SKScene에서 배경 이미지를 설정할 때. 아래 코드를 작성했습니다 :ios7의 MyScene에서 배경 이미지를 설정하는 방법
#import "JTEDMyScene.h"
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
@interface MyScene()
@property BOOL isContentCreated;
@end
@implementation MyScene
-(void) didMoveToView:(SKView *)view
{
if(!self.isContentCreated)
{
self.isContentCreated = YES;
[self createSceneContent];
}
}
-(void)createSceneContent
{
[self addChild:[self createBackground]];
}
-(SKSpriteNode *)createBackground
{
SKSpriteNode *backgroundSprite;
SKTexture *textureImage;
if (IS_IPAD) {
textureImage = [SKTexture textureWithImageNamed:@"home_ipad1.jpg"];
backgroundSprite = [SKSpriteNode spriteNodeWithTexture:textureImage];
}
backgroundSprite.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
return backgroundSprite;
}
장치 방향 모드는 가로 방향 및 가로 방향으로 만 나타납니다. 내 이미지 크기는 폭 = 1024이고 높이 = 768 및 264 dpi입니다. 그러나 이미지가 표시되는 부분이 완전히 보이지 않습니다.
Yah "Landscape Left"및 "Landscape Right"만 선택했습니다. 여기서 내 화면 너비는 1024이고 높이는 768입니다. –