Jump to content
  • Advertisement
Sign in to follow this  
Ultra The Vampire

simple problem

This topic is 4837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

code: -------------------------------------------------------------------------------- class PD_Level_Loader : public B_GameState { public: void Entity_Loader(); void Complete_Level(const char* level); }; void PD_Level_Loader::Complete_Level(const char* level) { irr::scene::ISceneNode* node = 0; m_device->getFileSystem()->addZipFileArchive("map-20kdm2.kp3"); irr::scene::IAnimatedMesh* mesh = m_smgr->getMesh("level"); if (mesh) node = m_smgr->addOctTreeSceneNode(mesh->getMesh(0)); irr::scene::ITriangleSelector* selector = 0; if (node) { node->setPosition(irr::core::vector3df(-1300,-144,-1249)); selector = m_smgr->createOctTreeTriangleSelector(mesh->getMesh(0), node, 128); node->setTriangleSelector(selector); selector->drop(); } irr::scene::ICameraSceneNode* camera = camera = m_smgr->addCameraSceneNodeFPS(); camera->setPosition(irr::core::vector3df(-100,50,-150)); irr::scene::ISceneNodeAnimator* anim = m_smgr->createCollisionResponseAnimator( selector, camera, irr::core::vector3df(30,50,30), irr::core::vector3df(0,-3,0), irr::core::vector3df(0,50,0)); camera->addAnimator(anim); anim->drop(); } gs_DemoFakeGame::gs_DemoFakeGame(B_GameStateHandler* handler) : B_GameState(handler) { PD_Level_Loader::Complete_Level("20kdm2.bsp"); m_guiSaveTextcolor = m_env->getSkin()->getColor( irr::gui::EGDC_BUTTON_TEXT ); m_env->getSkin()->setColor( irr::gui::EGDC_BUTTON_TEXT, IRRColor(0, 255,255,255) ); m_guiFPS = m_env->addStaticText(L"", IRRRectd(5, 5, 50, 25), false, false); m_guiFPS->setVisible( ICE_Options::getPreference("showFPS") == "T" ); } -------------------------------------------------------------------------------- Build started: Project: ICE_Demo, Configuration: Debug Win32 ------ Compiling... gs_DemoFakeGame.cpp c:\coding\irrlicht\ice\ICE_3.0\ICE_3\src\Demo\GameStates\gs_DemoFakeGame.cpp(44) : error C2352: 'PD_Level_Loader::Complete_Level' : illegal call of non-static member function c:\coding\irrlicht\ice\ICE_3.0\ICE_3\src\Demo\GameStates\gs_DemoFakeGame.cpp(9) : see declaration of 'PD_Level_Loader::Complete_Level' Build log was saved at "file://c:\coding\irrlicht\ice\Ice_3.0\Ice_3\projects\vc7.net.2003\Debug\BuildLog.htm" ICE_Demo - 1 error(s), 0 warning(s) ---------------------- Done ---------------------- Build: 0 succeeded, 1 failed, 0 skipped -------------------------------------------------------------------------------- what am i doing wrong here?

Share this post


Link to post
Share on other sites
Advertisement
You must create an object of type PD_Level_loader ie.

PD_Level_Loader loader;
loader.CompleteLevel( "20kdm2.bsp" );

Or you must make the CompleteLevel method static - in which case it may not use non-static data.

Share this post


Link to post
Share on other sites
"PD_Level_Loader::Complete_Level("20kdm2.bsp");" is a static call. For you to call a function in this way (this way == without instantiating a PD_Level_Loader object), Complete_Level() must be declared as static void Complete_Level(...), rather than just void. It also may then not contain any references to PD_Level_Loader member variables or non-static member functions.

Otherwise, you'd need to create a PD_Level_Loader object and then call the function from it, i.e.:

PD_Level_Loader loader;
loader.Complete_Level("20kdm2.bsp");


EDIT: Beaten to it. Hey, if two people say it, it must be right :D

Share this post


Link to post
Share on other sites
Quote:
Original post by Simian Man
You must create an object of type PD_Level_loader ie.

PD_Level_Loader loader;
loader.CompleteLevel( "20kdm2.bsp" );

Or you must make the CompleteLevel method static - in which case it may not use non-static data.


------ Build started: Project: ICE_Demo, Configuration: Debug Win32 ------

Compiling...
gs_DemoFakeGame.cpp
c:\coding\irrlicht\ice\ICE_3.0\ICE_3\src\Demo\GameStates\gs_DemoFakeGame.cpp(43) : error C2259: 'PD_Level_Loader' : cannot instantiate abstract class
due to following members:
'void B_GameState::Update(void)' : pure virtual function was not defined
c:\coding\irrlicht\ice\ICE_3.0\ICE_3\src\Framework\Base_Classes\B_GameState.h(27) : see declaration of 'B_GameState::Update'
'void B_GameState::Render(void)' : pure virtual function was not defined
c:\coding\irrlicht\ice\ICE_3.0\ICE_3\src\Framework\Base_Classes\B_GameState.h(28) : see declaration of 'B_GameState::Render'
'bool B_GameState::onEvent(irr::SEvent)' : pure virtual function was not defined
c:\coding\irrlicht\ice\ICE_3.0\ICE_3\src\Framework\Base_Classes\B_GameState.h(34) : see declaration of 'B_GameState::onEvent'
c:\coding\irrlicht\ice\ICE_3.0\ICE_3\src\Demo\GameStates\gs_DemoFakeGame.cpp(43) : error C2512: 'PD_Level_Loader' : no appropriate default constructor available

Build log was saved at "file://c:\coding\irrlicht\ice\Ice_3.0\Ice_3\projects\vc7.net.2003\Debug\BuildLog.htm"
ICE_Demo - 2 error(s), 0 warning(s)


---------------------- Done ----------------------

Build: 0 succeeded, 1 failed, 0 skipped
-----------------------------------------------------------------------------



thats what i got when i tried to make a object like you instructed me above.
I would like to thank you guys for taking the time to help me with this. Thank you.

Share this post


Link to post
Share on other sites
This means, to quote your error message, that PD_Level_Loader is an abstract class. To put that in laymans terms -- it's an object-orientedism that means that the class is designed not to be used directly, but implemented by classes further down the line. It appears you're using a couple APIs here -- Irrlicht for one, which I'm familiar with; also ICE, which I'm not familiar with. Since I'm not, all I can recommend is that you read the documentation that comes with ICE to figure out how PD_Level_Loader is supposed to be used.

Share this post


Link to post
Share on other sites
ICE is just framework for Irrlicht, nothing more.
PD_Level_Loader is a class i am coding to simplify to irrlicht level loading, i inherited the B_Gamestate class so i could access the irrlicht functions and classes.

i don't qoute understand what you mean (i've been studying C++ for a few years and still have'nt got everything down) i was trying to use it in the gs_demoFakeGame class constructor function.

does that mean i would have to make another class and inherit the functions from PD_Level_Loader to use them?
or should i try to find another way to access the B_GameState functions and not inherit them in the first place so I would get abstract member class proble (or would i still get them? don't know)

Share this post


Link to post
Share on other sites
Ahh, my apologies for the misunderstanding.

Since your PD_Level_Loader class derives from B_Gamestate, you need to provide implementations of B_Gamestate's virtual functions before you can instantiate it (in the way Simian Man and I suggested). The functions listed in the error message were:
void Update(void)
void Render(void)
bool onEvent(irr::SEvent)

You can get away with stubbing (making empty versions of) these functions for now, but eventually you may want to put code in the Update function. You'll probably never need code in the Render or onEvent functions since it's a "Level_Loader" (but I may be wrong).

I also noticed a "No appropriate default constructor available" message -- you will probably need to either provide a default constructor (empty parameter list), or call the constructor with parameters when you create the object (i.e. "PD_Level_Loader loader(args);").

Hope this helps,
Twilight Dragon

Share this post


Link to post
Share on other sites
thank you for the help.

sorry if this seems like a bigger problem that what i originally stated.
First i got a message about unresolved externals when i fixed the coding the way you told me and i assumed the externals message was caused by there being no constructor and destructor functions. I created 2 empty contructor/destructor functions.
Now i get this message below, problem is B_GameState has a contructor associated with it already in B_GameState.h

B_GameState(B_GameStateHandler* handler);

is there something i am doing wrong?
I changed the problematic coding to this

--------------------------------------------------------------------------------

class PD_Level_Loader :
public B_GameState
{

public:
void Entity_Loader();
void Complete_Level(const char* level);
void Update(void);
void Render(void);
bool onEvent(irr::SEvent);
PD_Level_Loader();
~PD_Level_Loader();
};

PD_Level_Loader::PD_Level_Loader()
{
}

PD_Level_Loader::~PD_Level_Loader()
{
}
-----------------------------------------------------------------------------

Although i did'nt create functions for Render,onEvent, or Update. I just listed them in the PD_Level_Loader class, because i would've just made empty functions for them anyways.
Here is the error message i currently getted below


------ Build started: Project: ICE_Demo, Configuration: Debug Win32 ------

Compiling...
gs_DemoFakeGame.cpp
c:\coding\irrlicht\ice\ICE_3.0\ICE_3\src\Demo\GameStates\gs_DemoFakeGame.cpp(18) : error C2512: 'B_GameState' : no appropriate default constructor available

Build log was saved at "file://c:\coding\irrlicht\ice\Ice_3.0\Ice_3\projects\vc7.net.2003\Debug\BuildLog.htm"
ICE_Demo - 1 error(s), 0 warning(s)


---------------------- Done ----------------------

Build: 0 succeeded, 1 failed, 0 skipped

Share this post


Link to post
Share on other sites
In the default constructor just created, you'll need a call to your superclass' (B_GameState) constructor with an appropriate B_GameStateHandler * variable. For example, if you've created a B_GameStateHandler * handler somewhere else:

PD_Level_Loader::PD_Level_Loader()
{
B_GameState(handler);
}


You probably know this, but just to be sure -- you do need to create and initialize the handler variable as the B_GameState constructor expects -- it might accept 0, you may need to create a new one with new, or you may need to call some specific creation function that returns it.

Cheers,
Twilight Dragon

Share this post


Link to post
Share on other sites
ok, this is what i have now, only now it says that PD_Level_Loader does'nt have a appropiate constructor...?

---------------------------------------------------------------------------class PD_Level_Loader :
public B_GameState
{

public:
void Entity_Loader();
void Complete_Level(const char* level);
void Update(void);
void Render(void);
bool onEvent(irr::SEvent);
PD_Level_Loader(B_GameStateHandler* handler);
~PD_Level_Loader(void);
};

PD_Level_Loader::PD_Level_Loader(B_GameStateHandler* handler) : B_GameState(handler)
{

}

PD_Level_Loader::~PD_Level_Loader(void)
{
}
----------------------------------------------------------------------------

This is error i am getting now

------ Build started: Project: ICE_Demo, Configuration: Debug Win32 ------

Compiling...
gs_DemoFakeGame.cpp
c:\coding\irrlicht\ice\ICE_3.0\ICE_3\src\Demo\GameStates\gs_DemoFakeGame.cpp(58) : error C2512: 'PD_Level_Loader' : no appropriate default constructor available

Build log was saved at "file://c:\coding\irrlicht\ice\Ice_3.0\Ice_3\projects\vc7.net.2003\Debug\BuildLog.htm"
ICE_Demo - 1 error(s), 0 warning(s)


---------------------- Done ----------------------

Build: 0 succeeded, 1 failed, 0 skipped

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!