【发布时间】:2013-03-26 23:31:19
【问题描述】:
现在我已经在应用商店中创建了我的游戏“激光防御者”及其应用程序,但我有一件事我不知道,如何将高分存储在游戏列表中。我有一个标签来计算被摧毁的敌舰数量,但是我如何将这些分数中最好的存储在一个列表中?这是我更新enemyShot标签的代码:
-
(void)update:(ccTime)dt {
NSMutableArray *projectilesToDelete = [[NSMutableArray alloc] init]; for (CCSprite *projectile in _projectiles) { CGRect projectileRect = CGRectMake( projectile.position.x - (projectile.contentSize.width/2), projectile.position.y - (projectile.contentSize.height/2), 弹丸.contentSize.width, projectile.contentSize.height);
NSMutableArray *targetsToDelete = [[NSMutableArray alloc] init]; for (CCSprite *target in _targets) { CGRect targetRect = CGRectMake( target.position.x - (target.contentSize.width/2), target.position.y - (target.contentSize.height/2), target.contentSize.width, target.contentSize.height); if (CGRectIntersectsRect(projectileRect, targetRect)) { [targetsToDelete addObject:target]; } } for (CCSprite *target in targetsToDelete) { [_targets removeObject:target]; [self removeChild:target cleanup:YES]; _enemiesShot++; [_enemiesShotLabel setString:[NSString stringWithFormat:@"%d",_enemiesShot]]; } if (targetsToDelete.count > 0) { [projectilesToDelete addObject:projectile]; } [targetsToDelete release];}
for (CCSprite *projectile in projectilesToDelete) { [_projectiles removeObject:projectile]; [self removeChild:projectile cleanup:YES]; } [projectilesToDelete 发布];
}
【问题讨论】:
-
“list”是指“NSUSerDefaults”,还是仅在应用程序运行时才需要?
-
无论应用程序是否运行,我都想将所有最高分存储在一个列表中。
标签: ios6 cocos2d-iphone xcode4.5