私はSFMLで簡単なプログラムを作成しようとしています。これまでは、メインファイルとウィンドウを開くファイルとそのファイルのヘッダーがあります。ヘッダーC++のUnqualified-Idが必要です
C:私はこのエラーを取得する
#ifndef Window.hpp
#define Window.hpp
Window();
int Loop();
#endif
:事は、私は、ヘッダの問題を持っていたされています... \ Window.hpp | 4 |エラー:予想される修飾されていない-ID」の前に。 'トークン|
ウィンドウファイルは次のとおりですから
#import <SFML/Window.hpp>
#import <iostream>
// This file needs to create and maintain the program's window, and change it's state.
class Window
{
sf::RenderWindow appWindow;
sf::Image charImage;
sf::Sprite charSpriteSheet;
public:
Window();
int Loop();
}
Window::Window()
{
appWindow.Create(sf::VideoMode(800, 600, 32), "AI_Fighter");
if(!charImage.LoadFromFile("Bass.png"))
{
cout << "Problem opening file 'Bass.png'";
}
charSpriteSheet.SetImage(charImage);
}
int Window::Loop()
{
// Start game loop
while (appWindow.IsOpened())
{
sf::Event evt;
while (appWindow.GetEvent(evt))
{
// Window closed
if (evt.Type == sf::Event::Closed)
appWindow.Close();
// Escape key pressed
if ((evt.Type == sf::Event::KeyPressed) && (evt.Key.Code == sf::Key::Escape))
appWindow.Close();
}
// Get elapsed time
float ElapsedTime = appWindow.GetFrameTime();
// Move the sprite
if (appWindow.GetInput().IsKeyDown(sf::Key::Left)) charSpriteSheet.Move(-100 * ElapsedTime, 0);
if (appWindow.GetInput().IsKeyDown(sf::Key::Right)) charSpriteSheet.Move(100 * ElapsedTime, 0);
if (appWindow.GetInput().IsKeyDown(sf::Key::Up)) charSpriteSheet.Move(0, -100 * ElapsedTime);
if (appWindow.GetInput().IsKeyDown(sf::Key::Down)) charSpriteSheet.Move(0, 100 * ElapsedTime);
// Rotate the sprite
if (appWindow.GetInput().IsKeyDown(sf::Key::Add)) charSpriteSheet.Rotate(-100 * ElapsedTime);
if (appWindow.GetInput().IsKeyDown(sf::Key::Subtract)) charSpriteSheet.Rotate(100 * ElapsedTime);
// Clear the screen (fill it with black color)
appWindow.Clear(sf::Color(0, 0, 0));
appWindow.Draw(charSpriteSheet);
// Display window contents on screen
appWindow.Display();
}
}
には、私は '#のdefine'で許可されている.''とは思いません定数。 – RedX