Thursday 15 September 2011

ios6 - How to store high scores in a list in Cocos2d -


I have already created my own game in "Laser Defender" and App Store, but I have one thing that I do I can not find out how to submit a high score in a list of game games, I have a label that calculates the number of enemy ships destroyed, but I can list the best of these points in the list. How do I archive? Here my code updates the enemiesShot label:

  • (zero) Update: (ccTime) DT {

    NSMutableArray * projectilesToDelete = [[NSMutableArray alloc] init ]; For (CCSprite * throwing in _projectiles) {CGRect projectileRect = CGRectMake (projectile.position.x - (projectile.contentSize.width / 2), projectile.position.y - (projectile.contentSize.height / 2), projectile.contentSize Width, projectile.contentSize.height);

      NSMutableArray * targetsToDelete = [[NSMutableArray alloc] init]; (Target.contentSize.width / 2), target.position.y - - (CCSprite * Targets in _targets) {CGRect targetRect = CGRectMake (target.contentSize.height / 2) for target.position.x, target.contentSize Width, target.contentSize.height); If (CGRTEXectorSect (Project Protect, Target)) {[TargetOdellAlletAdd Object: Target]; }} (Remove target in CCSprite * target) {{_ targetsObject: target]; [Self-distribil: target cleaning: yes]; _enemiesShot ++; [_enemiesShotLabelSetString: [NSString stringWithFormat: @ "% d", _SharutoShot]]; } If (targets TIDELETQATT> 0) {[ProjectsAdelitalAdobject: ProjectClass]; } [To release the target]   

    }

    (throwing CCSpact * in Projectsdomyale) {[ProPixix deleted object: project]; [Remove self: projectile cleaning: yes]; } [ProjectilesToDelete release];

    try this:

    NSUserDefaults

    Saving

      NSUserDefaults * Rank = [NSUserDefaults standardUserDefaults]; // Saving an NSString [Prefetch Set Object: @ "TextOverWave" for: @ "Pest Lookup String"]; // An NSInteger Savings [Prefix Set Integer: For 42: @ "Integerkey"]; // one for double [prefess setdeud double: 3.1415 ky: @ "double key"]; // A Float Savings [Prefetch Setflat: for 1.2345678: @ "Float"]; // It has been suggested to synchronize the prefus, [synchronize the prefus];   

    Recovering NSUserDefaults * prefs = [NSUserDefaults Standard User Default]; // Getting a NSString NSString * myString = [Prefs stringForKey: @ "keyToLookupString"]; // An NSInteger NSInteger myInt = [Prefs integerForKey: @ "integerKey"] is getting; // A float float is my float = [prefix flatfork: @ "float"];

    The app is currently running some data in some NSA / MTA and when the app is going to the background, the "Saving" section is part of the "Edender Background".

    When the app starts again, then withdraw all data from "User Defaults" (Recover Code above). Place the code inside "ApplicationDidEnterForeground" when the application is started fresh, then use "ViewDidLoad" to retrieve the code.

No comments:

Post a Comment