我通过在 Xcode 中创建小型控制台游戏来学习 Objective C。我目前正在制作一种战舰网格游戏。除了玩家通过 scanF 输入坐标之外,有没有一种方法可以实现箭头键的使用?我检查了苹果文档,但找不到任何类方法。
这是我希望玩家导航的代码:
NSMutableArray *theBoard = [[NSMutableArray alloc]init];
for (int i = 1; i < 101; i++) {
[theBoard addObject:[NSString stringWithFormat:@"%02d",i]];
}
// this prints the board to console
for (int i = 0; i < 10; i++) {
NSLog(@" %@",[[theBoard subarrayWithRange:NSMakeRange(0+(i*10) , 10)]componentsJoinedByString:@" "]);
}