2015-01-02 4 views
1

저는 Cocos2D 2.1을 사용하고 있으며,이 응용 프로그램은 망막과 망막이 아닌 iPad에서만 사용할 수 있습니다. spriteWithFile을 사용하고 -hd 접미사없이 파일 이름을 지정할 때 Cocos2D는 -hd 접미어가있는 이미지를 찾아서 사용하지만 표준 해상도로 표시합니다. 즉, 망막 이미지로 표시되도록 축소되지 않습니다. 내 대리인의에서Cocos2D HD spriteWithFile가 SD로 표시됩니다.

- (BOOL) 응용 프로그램 : (UIApplication *) 응용 프로그램의 didFinishLaunchingWithOptions :

CCGLView *glView = [CCGLView viewWithFrame:[window_ bounds] 
            pixelFormat:kEAGLColorFormatRGBA8 
            depthFormat:GL_DEPTH24_STENCIL8_OES 
          preserveBackbuffer:NO 
            sharegroup:nil 
           multiSampling:NO 
           numberOfSamples:0]; 

[glView setMultipleTouchEnabled:YES]; 

director_ = (CCDirectorIOS*) [CCDirector sharedDirector]; 

[director_ setDisplayStats:YES]; 

[director_ setAnimationInterval:1.0/60]; 


// attach the openglView to the director 
[director_ setView:glView]; 

// 2D projection 
[director_ setProjection:kCCDirectorProjection2D]; 

[director_ enableRetinaDisplay:YES]; 

// // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices 
if(! [director_ enableRetinaDisplay:NO]) 
    CCLOG(@"Retina Display Not supported"); 

// If the 1st suffix is not found and if fallback is enabled then fallback suffixes are going to searched. If none is found, it will try with the name without suffix. 
CCFileUtils *sharedFileUtils = [CCFileUtils sharedFileUtils]; 
[sharedFileUtils setEnableFallbackSuffixes:NO]; // Default: NO. No fallback suffixes are going to be used 

[sharedFileUtils setiPadRetinaDisplaySuffix:@"-hd"]; 

glView.opaque = NO; 
glClearColor(0.0f,0.0f,0.0f,0.0f); 
//glClear(GL_COLOR_BUFFER_BIT); 

// Assume that PVR images have premultiplied alpha 
[CCTexture2D PVRImagesHavePremultipliedAlpha:YES]; 

내가 spriteWithFile를 사용하여 스프라이트를 추가 할 때 (대신 사용 : (NSDictionary와 *) launchOptions 방법, 나는 다음과 같은 한 스프라이트 시트 그것은 단지 하나 개의 이미지 때문에) 나는 다음과 같은 코드가 있습니다

movingTileGroup.handleSprite1 = [CCSprite spriteWithFile:@"draggableTileGroupHandle.png"]; 

movingTileGroup.handleSprite1.position = ccp(x,y); 

[self.theMap addChild:movingTileGroup.handleSprite1 z:13]; 
이 이

업데이트 : 때 볼 - (BOOL) enableRetinaDisplay : (BOOL이)라고 활성화의 경우 중 어느 것도 문 마지막 ret하지를 진정한 urn. 스케일 팩터 설정과 관련이있을 수 있습니까? 내가 그 경우는, 스프라이트를 생성하는 Spritebuilder를 사용하는 가정입니다

-(BOOL) enableRetinaDisplay:(BOOL)enabled 
{ 
    NSLog(@"enableRetinaDisplay called"); 
    // Already enabled ? 
    if(enabled && __ccContentScaleFactor == 2){ 
     NSLog(@"enabled && __ccContentScaleFactor == 2 "); 
     return YES; 
    } 

    // Already disabled 
    if(! enabled && __ccContentScaleFactor == 1){ 
     NSLog(@"! enabled && __ccContentScaleFactor == 1 "); 
     return YES; 
    } 

    // setContentScaleFactor is not supported 
    if (! [__view respondsToSelector:@selector(setContentScaleFactor:)]){ 
     NSLog(@"setContentScaleFactor is not supported"); 
     return NO; 
    } 
    // SD device 
    if ([[UIScreen mainScreen] scale] == 1.0){ 
     NSLog(@"SD device"); 
     return NO; 
    } 

    float newScale = enabled ? 2 : 1; 
    [self setContentScaleFactor:newScale]; 

    // Load Hi-Res FPS label 
    [[CCFileUtils sharedFileUtils] buildSearchResolutionsOrder]; 
    [self createStatsLabel]; 

    return YES; 
} 

답변

0

그래서 당신이 spritebuilder 소프트웨어 이미지의 기본 크기를 지정해야합니다,이은을 보여주는 이미지를 클릭하여 수행 할 수 있습니다 문제를 선택한 다음 왼쪽 사이드 바 또는 패널에서 이미지 크기를 "기본값"으로 선택하면 자동으로 필요한 크기로 조정됩니다.

그래도 문제가 해결되지 않으면 ... 알려주세요. ...

+0

나는 스프라이트 시트를 만들기 위해 Zwoptex를 사용하고 있지만,이 경우에는 단일 png 이미지 만 사용하므로 스프라이트 시트가 필요하지 않습니다. (이것이 내가 spriteWithFile을 사용하는 이유입니다.) 망막에서 올바르게 표시되도록 너비와 높이를 지정하는 스프라이트 시트를 사용해야한다는 것일 수도 있습니다. – VagueExplanation

+0

내가 알아 낸 또 다른 점은 내 메인 게임 레이어의 스프라이트 시트로 작동하도록 망막 그래픽을 얻을 수 없다는 것입니다.하지만 그들은 내 사용자 지정 시차 레이어에서 수행합니다. 이 문제에 대한 의견을 보내 주셔서 감사합니다.하지만이 발견을 기반으로 새로운 스레드를 만들어이 스레드를 닫을 것이라고 생각합니다. – VagueExplanation