如何让玩家按任意键继续

How to Let Players Press Any Key to Continue?

本文关键字:任意键 继续 玩家      更新时间:2023-10-16

我想让玩家按任意键继续游戏,但不知道怎么做。下面是我到目前为止的代码:

#include <iostream>
#include <string>
using namespace std;
int main()
{
    cout << "ttWelcome to my first game, A Hero's Journey!nn";
    char response;
    cout << "tttPress any key to continue!: nn";
    cin >> response;
    if (response == 
    return 0;
}

我目前正在处理if语句,所以忽略它,除非这是我决定玩家是否按压某事的地方。

不需要if条件,因为cin总是等待输入。如果您要求用户输入一个特定的键,那么您需要一个If条件来检查它。