error C2039: 'GameData' : is not a member of 'sf'

Jul 28, 2014 at 4:43pm
Error C2039: 'GameData' : is not a member of 'sf'

Been trying to figure the problem out for a while now and just can't get my head around it. Any solutions anyone?

Thanks in advance!

(SOURCE: LJMUGame.h)
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
//---------CLASS MEMBERS---------------------------------------------------
		sf::RenderWindow						_wndw;			//The SFML Graphics Window
		sf::LJMUResourceHelper<sf::Texture,int> _sprite_res;	//Resource Manager for Textures
		sf::LJMUResourceHelper<sf::Font,int>   	_font_res;      //Resource Manager for Fonts

		sf::Sprite								_player_spr;                  //Player Sprite

		sf::PlayerData                          _player_data;                 //Data Container for the Player
		sf::GameData                            _game_data;					  //Data Container for the Game

		sf::FloatRect                           _left_edge;		//Left Screen Edge
		sf::FloatRect                           _right_edge;	//Right Screen Edge
		sf::FloatRect                           _top_edge;		//Top Screen Edge
		sf::FloatRect                           _btm_edge;		//Bottom Screen Edge

		sf::Text                                _arr_text[HE_COUNT];      //Text to display HUD
		sf::Text								_text_fps;		          //Text to Display the Frame Rate
		sf::Font								_font;			          //Our Default Font
				
		sf::Time								_time_tpf;      //Time object storing the current time per frame
		sf::Time								_time_update;	//Time object storing the current update time

		sf::String								_app_name;		//String representing the window title
		sf::VideoMode							_app_vmode;		//SFML Video Mode representing the screen mode
		sf::Color								_text_clr;		//Colour of our debug text. 
		sf::Color								_wnd_clr;		//Colour of our Clear Window
		unsigned int 							_app_style;		//Enum value representing the style of SFML Window (FullScreen etc). 
};

#endif  


(SOURCE: LJMUBrickBreaker.h)
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
#pragma once

#include <SFML/Graphics.hpp>

namespace sf
{

struct GameData
{	
	int  score;
	bool gameover;

	GameData()
	{
		score = 0;
		

	}
};

struct PlayerData
{
	int nolives;
	bool active;
	bool  is_move_left;						
	bool  is_move_right;	
	PlayerData()
	{
		active	      = true;
		nolives		  = 3;
		is_move_left  = false;
		is_move_right = false;
	}
};

}

Jul 28, 2014 at 5:03pm
Adding your types to the sf namespace is bad practice.

You need to #include "LJMUBrickBreaker.h" in LJMUGame.h.
Jul 28, 2014 at 5:10pm
I have included the "LJMUBrickBreaker.h" in LjmuGame.h. My bad, should of posted the whole code really.

Here it is..

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef __LJMU_GAME_H_
#define __LJMU_GAME_H_

//Include the SFML Graphics Header - This will include all other main Headers.
#include <SFML/Graphics.hpp>

//Include our LJMU Utility Class Header. 
#include "LJMUSFML/LJMUSFMLUtil.h"
#include "LJMUSFML/LJMUPolar.h"

#include "LJMUBrickBreaker.h"

////////////////////////////////////////
// LJMUGAME.H / LJMUGAME.CPP
// Class to represent our basic SFML Game
// Application.	
//
// AUTHOR:  JACK MIDDLETON
////////////////////////////////////////
class LJMUGame : private sf::NonCopyable
{
	public:
		//---------ENUMERATIONS AND ENUMERATED ARRAYS------------------------------
		enum HUDElements		{ HUD_SCORE, HUD_LIVES, HE_COUNT};		

		//---------CONSTRUCTORS / DESTRUCTORS--------------------------------------
		LJMUGame(void);					//Constructor for the Game Class
		~LJMUGame(void);				//Destructor for the Game Class


		//---------PUBLIC METHODS--------------------------------------------------
		void	runGameLoop();			//Method which controls the entire game loop of the application
		
	private:
		//---------INTERNAL METHODS------------------------------------------------
		void    initialise();			//Initialise the State of the Window 
		void    loadContent();          //Load any content reliant on the GPU
		void	handleEvents();         //Process our Input Events
		void	update(sf::Time ptpf);  //Update the State of the Game
		void	render();				//Draw the Screen
		void    cleanup();				//Cleanup any object
		void	handleInput(sf::Keyboard::Key pkey, bool ppressed); //Poll for Input from our Input Devices
		
		void	updateFPS();			//Update the Frames Per Second Display
		void    outputContext();		//Output the Current Window Settings to the console
		void    updateDebugText(sf::Sprite& psprite,sf::Text& ptext,sf::String& pname); //Output the state of the sprite
		
		static sf::String getSpriteState(sf::Sprite& psprite,sf::String& pname); //Get the state of the sprite
		static void setOriginCentre(sf::Sprite& psprite); //Set the Origin of our Sprite to the centre.


	private:
		//---------CONSTANTS-------------------------------------------------------
		static const sf::Time		DEFAULT_APP_TARGET_TPF;		//Constant to represent the target frame rate
		static const std::string	DEFAULT_APP_NAME;			//Constant to represent the default application name
		static const bool			DEFAULT_APP_FS_MODE;		//Constant to represent whether we are fullscreen or not
		static const char			DEFAULT_APP_VIDEO_MODE;		//Constant to represent which video mode to use (U for Custom 'User', B for Best, D for Current Desktop)

		static const unsigned int	DEFAULT_APP_CUST_WIDTH;		//Constant to represent the custom mode display width
		static const unsigned int	DEFAULT_APP_CUST_HEIGHT;	//Constant to represent the height of the window
		static const unsigned int	DEFAULT_APP_CUST_CDEPTH;	//Constant to represent the Colour Depth in bits

		static const unsigned int   DEFAULT_OGL_DEPTH_BUFF;		//Constant to represent the OpenGL Depth Buffer Size in Bits
		static const unsigned int   DEFAULT_OGL_STENCIL_BUFF;	//Constant to represent the OpenGL Stencil Buffer Size in Bits
		static const unsigned int   DEFAULT_OGL_VERSION_MAJOR;	//Constant to represent the OpenGL API Major (e.g. 4 in version 4.2)
		static const unsigned int   DEFAULT_OGL_VERSION_MINOR;  //Constant to represent the OpenGL API Minor (e.g. 2 in version 4.2)
		static const unsigned int   DEFAULT_OGL_MSAA_MODE;		//Constant to represent the MSAA Anti-Aliasing Mode (0x,1x,2x,4x,8x,16x etc.)
		
		//---------CLASS MEMBERS---------------------------------------------------
		sf::RenderWindow						_wndw;			//The SFML Graphics Window
		sf::LJMUResourceHelper<sf::Texture,int> _sprite_res;	//Resource Manager for Textures
		sf::LJMUResourceHelper<sf::Font,int>   	_font_res;      //Resource Manager for Fonts

		sf::Sprite								_player_spr;                  //Player Sprite

		sf::GameData                            _game_data;					  //Data Container for the Game
		sf::PlayerData                          _player_data;                 //Data Container for the Player

		sf::FloatRect                           _left_edge;		//Left Screen Edge
		sf::FloatRect                           _right_edge;	//Right Screen Edge
		sf::FloatRect                           _top_edge;		//Top Screen Edge
		sf::FloatRect                           _btm_edge;		//Bottom Screen Edge

		sf::Text                                _arr_text[HE_COUNT];      //Text to display HUD
		sf::Text								_text_fps;		          //Text to Display the Frame Rate
		sf::Font								_font;			          //Our Default Font
				
		sf::Time								_time_tpf;      //Time object storing the current time per frame
		sf::Time								_time_update;	//Time object storing the current update time

		sf::String								_app_name;		//String representing the window title
		sf::VideoMode							_app_vmode;		//SFML Video Mode representing the screen mode
		sf::Color								_text_clr;		//Colour of our debug text. 
		sf::Color								_wnd_clr;		//Colour of our Clear Window
		unsigned int 							_app_style;		//Enum value representing the style of SFML Window (FullScreen etc). 
};

#endif  


I've also been following tutorials from our tutor and adding our types to sf namespace is the way he has taught us sadly.
Last edited on Jul 28, 2014 at 5:10pm
Jul 28, 2014 at 5:14pm
Okay, seems I fixed the issue, for some reason I had two different "LJMUBrickBreaker.h". I was simply linking to the wrong one, thanks for your help.
Topic archived. No new replies allowed.