本文整理汇总了C++中FileIO::ReadSavedData方法的典型用法代码示例。如果您正苦于以下问题:C++ FileIO::ReadSavedData方法的具体用法?C++ FileIO::ReadSavedData怎么用?C++ FileIO::ReadSavedData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileIO
的用法示例。
在下文中一共展示了FileIO::ReadSavedData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UsingTitle
void GameController::UsingTitle()
{
//Press W,S to select the menuitem.
//Press J to use the menuitem.
SetPosition(62, 20);
cout << " " << flush;
switch (hitkey)
{
case TITLE_MENU_UP: {//Move the '->' up.
if (Scene.GetTitleCursorPositionY() >= 16)
{
SetPosition(Scene.GetTitleCursorPositionX(), Scene.GetTitleCursorPositionY());
cout << " " << flush;
Scene.SetTitleCursorPositionY(Scene.GetTitleCursorPositionY() - 2);
}; break;
}
case TITLE_MENU_DOWN: {//Move the '->' down.
if (Scene.GetTitleCursorPositionY() <= 18)
{
SetPosition(Scene.GetTitleCursorPositionX(), Scene.GetTitleCursorPositionY());
cout << " " << flush;
Scene.SetTitleCursorPositionY(Scene.GetTitleCursorPositionY() + 2);
}; break;
}
case TITLE_MENU_PRESS: {
switch (Scene.GetTitleCursorPositionY())
{
case 14: {
Scene.TitleClear();
game_start = true;
}; break;
case 16: {
Scene.DrawSelectSavedDataArea();
SetPosition(Scene.GetSavedDataCursorPositionX(), Scene.GetSavedDataCursorPositionY());
cout << "->" << flush;
//The followings are the operations of reading the saved data.
while (1)
{
if (_kbhit())
{
hitkey = _getch();
if (hitkey == 'k')
{
Scene.SelectSavedDataAreaClear();
break;
}
switch (tolower(hitkey))
{
case TITLE_MENU_UP: {
if (Scene.GetSavedDataCursorPositionY() >= 12)
{
SetPosition(Scene.GetSavedDataCursorPositionX(), Scene.GetSavedDataCursorPositionY());
cout << " " << flush;
Scene.SetSavedDataCursorPositionY(Scene.GetSavedDataCursorPositionY() - 1);
}
}break;
case TITLE_MENU_DOWN: {
if (Scene.GetSavedDataCursorPositionY() <= 19)
{
SetPosition(Scene.GetSavedDataCursorPositionX(), Scene.GetSavedDataCursorPositionY());
cout << " " << flush;
Scene.SetSavedDataCursorPositionY(Scene.GetSavedDataCursorPositionY() + 1);
}
}break;
case TITLE_MENU_PRESS: {
//The class FileIO will start to work here.
switch (Scene.GetSavedDataCursorPositionY())//The cursor's y position will decide which data to be changed.
{
case 11: {
FileIO fileIO;
fileIO.ReadSavedData("saveddata1.txt"); //Then the important information in the game will be initialized.
}break;
case 12: {
FileIO fileIO;
fileIO.ReadSavedData("saveddata2.txt");
}break;
case 13: {
FileIO fileIO;
fileIO.ReadSavedData("saveddata3.txt");
}break;
case 14: {
FileIO fileIO;
fileIO.ReadSavedData("saveddata4.txt");
}break;
case 15: {
FileIO fileIO;
fileIO.ReadSavedData("saveddata5.txt");
}break;
case 16: {
FileIO fileIO;
fileIO.ReadSavedData("saveddata6.txt");
}break;
case 17: {
FileIO fileIO;
fileIO.ReadSavedData("saveddata7.txt");
}break;
//.........这里部分代码省略.........
示例2: UsingMenu
//.........这里部分代码省略.........
if (_kbhit())
{
hitkey = _getch();
if (hitkey == 'k')
{
Scene.SelectSavedDataAreaClear();
Scene.RedrawCharaters();
break;
}
switch (hitkey)
{
case MENU_UP: {
if (Scene.GetSavedDataCursorPositionY() >= 12)
{
SetPosition(Scene.GetSavedDataCursorPositionX(), Scene.GetSavedDataCursorPositionY());
cout << " " << flush;
Scene.SetSavedDataCursorPositionY(Scene.GetSavedDataCursorPositionY() - 1);
}
}break;
case MENU_DOWN: {
if (Scene.GetSavedDataCursorPositionY() <= 19)
{
SetPosition(Scene.GetSavedDataCursorPositionX(), Scene.GetSavedDataCursorPositionY());
cout << " " << flush;
Scene.SetSavedDataCursorPositionY(Scene.GetSavedDataCursorPositionY() + 1);
}
}break;
case MENU_PRESS: {
//The class FileIO will start to work here.
switch (Scene.GetSavedDataCursorPositionY())//The cursor's y position will decide which data to be changed.
{
case 11: {
fileIO.ReadSavedData("saveddata1.txt"); //Then the important information in the game will be initialized.
}break;
case 12: {
fileIO.ReadSavedData("saveddata2.txt");
}break;
case 13: {
fileIO.ReadSavedData("saveddata3.txt");
}break;
case 14: {
fileIO.ReadSavedData("saveddata4.txt");
}break;
case 15: {
fileIO.ReadSavedData("saveddata5.txt");
}break;
case 16: {
fileIO.ReadSavedData("saveddata6.txt");
}break;
case 17: {
fileIO.ReadSavedData("saveddata7.txt");
}break;
case 18: {
fileIO.ReadSavedData("saveddata8.txt");
}break;
case 19: {
fileIO.ReadSavedData("saveddata9.txt");
}break;
case 20: {
fileIO.ReadSavedData("saveddata10.txt");
}break;
}
}break;
}
SetPosition(Scene.GetSavedDataCursorPositionX(), Scene.GetSavedDataCursorPositionY());