objective c - Why is second value (Null) when reading data from plist? -
this problem makegameswith.us website , peeved penguin project. attempting modify read level data plist rather gamelayer.mm, first sprite data reads in expected second pass through while loop returns (null) sprite name. i've looked @ plist, both sprites should have same file name "tallblock".
here relevant snippet of code:
cclog(@"about load level data."); // load level data , 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; // 1 of sprite names invalid... while (object = [enumerator nextobject]) { spritename = [object objectforkey: @"spritename"]; spritefile = [spritename stringbyappendingstring:@".png"]; cclog(@"sprite file : %@", spritefile); // second sprite doesn't load 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.");
i put problem/issue in official forum, i've received no advice. i've stepped through code many times in debugger , don't understand why finds tallblocks on pass 1 not on pass two.
i took screenshot of plist file. ideas why code fails on second sprite?
there's r missing in item 1's spritename...
Comments
Post a Comment