Hey Spieleprogrammiergemeinde,
ich steh grad vor einem kleinem problemchen. Ich bin einfach zu blind den fehler zu sehen.
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#ifndef _ENGINE_H
#define _ENGINE_H
#include <SFML\Graphics.hpp>
class Engine {
private:
int tileSize;
sf::Vector2i videoSize;
sf::RenderWindow window;
void MainLoop();
void RenderFrame();
int gamestate;
public:
void init();
Engine(int w, int h, int tileSize);
~Engine();
int getGamestate();
void setGamestate(int gs);
const enum eGameState {
SPLASH, MENU, GAME, PAUSE
};
};
#endif
|
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include "Engine.h"
#include "Events.h"
Engine::Engine(int w, int h, int tileSize) {
videoSize = sf::Vector2i(w, h);
this->tileSize = tileSize;
gamestate = GAME;
};
Engine::~Engine() {
};
void Engine::init() {
window.create(sf::VideoMode(videoSize.x, videoSize.y, 32), "RPG");
window.setFramerateLimit(300);
MainLoop();
};
void Engine::MainLoop() {
while (window.isOpen()) {
processInput(window);
RenderFrame();
}
};
void Engine::RenderFrame() {
window.display();
};
int Engine::getGamestate() {
return gamestate;
};
void Engine::setGamestate(int gs) {
gamestate = gs;
};
|
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
#include "Events.h"
#include "Engine.h"
void processInput(sf::RenderWindow& window) {
sf::Event evt;
if (Engine::getGamestate() == Engine::GAME) { //<- hier liegt der hund begraben
while (window.pollEvent(evt)) {
if (evt.type == sf::Event::Closed) {
window.close();
}
}
}
};
|
ich habe mal die zeile markiert die mir als fehler ausgegeben wird.
die frage ist, wieso mir der compiler mir sagt dass ein nicht statische rmemberverweib relativ zum objekt sein muss
ist es eine schlichte getmethode, ich verstehe einfach nicht wieso es nicht klappt oO
hoffe ihr könnt mir helfen
mit freundlichem gruß KrayZee