2013-04-19 3 views
0

이 문제는 makegameswith.us 웹 사이트와 Peeved Penguin 프로젝트의 문제입니다. GameLayer.mm보다는 plist에서 레벨 데이터를 읽으려고 수정하려고합니다. 첫 번째 스프라이트 데이터는 두 번째 패스가 while 루프를 통해 스프라이트 이름을 반환합니다 (Null). 나는 plist를 보았고, 두 스프라이트 모두 같은 이름의 "tallblock"을 가져야한다.plist에서 데이터를 읽을 때 두 번째 값 (Null)은 왜입니까?

여기에 코드의 관련 조각입니다 :

CCLOG(@"About to load level data."); 

    // Load Level Data and Draw Level Sprits 
    NSString *path = [[NSBundle mainBundle] pathForResource:@"Level1" ofType:@"plist"]; 
    NSDictionary *level = [NSDictionary dictionaryWithContentsOfFile:path]; 
    NSArray *levelBlocks = [level objectForKey:@"Blocks"]; // Capitalization matters 

    NSEnumerator *enumerator = [levelBlocks objectEnumerator]; 
    id object; 
    NSString *spriteName; 
    NSString *spriteFile; 
    NSNumber *xPos; 
    NSNumber *yPos; 

    // One of my sprite names is invalid... 
    while (object = [enumerator nextObject]) 
    { 
     spriteName = [object objectForKey: @"spriteName"]; 
     spriteFile = [spriteName stringByAppendingString:@".png"]; 

     CCLOG(@"Sprite File is : %@", spriteFile); // Second sprite doesn't load is null... 
     sprite = [CCSprite spriteWithFile: spriteFile]; 
     xPos = [object objectForKey: @"x"]; 
     yPos = [object objectForKey: @"y"]; 
     sprite.position = CGPointMake([xPos floatValue], [yPos floatValue]); 
     [blocks addObject:sprite]; 
     [self addChild: sprite 
        z: 7]; 
    } 

    CCLOG(@"Finished Loading Level Data."); 

나는이 문제/문제 in the official forum를 넣어,하지만 난 어떤 조언을받지했습니다. 나는 디버거에서 여러 번 코드를 밟았으며 패스 2에서 패스 블록 1에서 톨 블록을 발견하는 이유를 이해할 수 없습니다.

나는 plist 파일의 스크린 샷을 찍었습니다. 두 번째 스프라이트에서 코드가 실패하는 이유는 무엇입니까?

Plist Screen Shot

답변

1

거기에 R이 ... 항목 1의 spriteName에서 실종

+0

제기랄 반대로 키 'spiteName를'있다! 나는 열쇠의 이름이 아닌 파일의 이름을 보았다. 나는 이것에 많은 시간을 보냈다. 그리고 그것은 어리석은 'r'다. .. – Muskie

0

두 번째 배열 항목에 'spriteName'

관련 문제