iphone - Levels - Cocos2d -
i have 10 levels. normal game, can't play next level unless beat level before it. parts change on each level is, 1 sprite , sprite's position.
how make if beat level next level unlocks, distinguishes level on , loads defined "details"(meaning sprite file , position)?
any great appreciated! thanks!
edit:
i used plist load information regarding level
first, created plist(right click group then, click resources, "property list"). next, defined information within plist.
then, set global variable set level number. when user chooses whichever level(which ccmenu), method changes int "level" correct level number(e.g. 1,2,3,4,5). then, in game init checks int "levels" , runs level plist.
this in level methods gamescene init runs after level check. loads plist, sets dictionary, chooses background, adds layer, ints "_ballx, _bally" declared in .h file sets value ball's position located in init!
nsstring *path = [[nsbundle mainbundle] bundlepath]; nsstring *finalpath = [path stringbyappendingpathcomponent:@"levels.plist"]; nsdictionary *plistdataall = [[nsdictionary dictionarywithcontentsoffile:finalpath] retain]; nsdictionary *leveldata = [nsdictionary dictionarywithdictionary:[plistdataall valueforkey:@"levelone"]]; nsstring *background = [leveldata objectforkey:@"levelbackground"]; _m = [ccsprite spritewithfile:background]; _m.anchorpoint = ccp(0, 0); _m.position = ccp(0, 0); [self addchild:_m]; _ballx = [[leveldata valueforkey:@"ballpositionx"] intvalue]; _bally = [[leveldata valueforkey:@"ballpositiony"] intvalue];
hope helps someone! thank quick responses!
have level class load data level data file (a plist file, or xml, or whatever). whenever want load different level point different data file.
as unlocking levels, make array of levels along locked/unlocked status level select class uses display different levels. between games information can stored in data file (again, plist file, or xml, or using coredata).
Comments
Post a Comment