【问题标题】:using Arrow keys to navigate around a console app使用箭头键在控制台应用程序中导航
【发布时间】:2011-11-04 17:17:48
【问题描述】:

我通过在 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:@"  "]);
}

【问题讨论】:

    标签: objective-c console-application arrow-keys


    【解决方案1】:

    Mac OS X 包含 Ncurses,这是一个用于创建基于控制台的 UI 的有用库。

    【讨论】:

      猜你喜欢
      • 2011-10-08
      • 2011-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多