I have exactly 0 knowledge of c++ / oo, only a minimal grasp on c, and I assume this is pretty obvious.In the body of the constructor we need to assign the passed arguments to the proper variables.
If somebody can point me in the right direction, it would be greatly appreciated. Even with my limited knowledge I managed to make a 2d minigame with the dx9sdk, but for some reason I'm just not grasping this.
This is my turtorialframelistener.cpp file (spaceframelistener.cpp in my project)
Code: Select all
#include "spaceframelistener.h"
SpaceFrameListener::SpaceFrameListener(RenderWindow* win, Camera* cam,
SceneNode* controlNode,
SceneNode* shipNode,
SceneNode* cameraNode)
{
mControlNode = controlNode;
mShipNode = shipNode;
mCameraNode = cameraNode;
mbFirstPerson = false;
}
bool SpaceFrameListener::frameStarted(const FrameEvent& evt)
{
Real MoveFactor = 80.0 * evt.timeSinceLastFrame;
mInputDevice->capture();
if(mInputDevice->isKeyDown(Ogre::KC_UP))
mControlNode->translate(0.0, MoveFactor, 0.0);
if(mInputDevice->isKeyDown(Ogre::KC_DOWN))
mControlNode->translate(0.0, -MoveFactor, 0.0);
if(mInputDevice->isKeyDown(Ogre::KC_LEFT))
mControlNode->translate(-MoveFactor, 0.0, 0.0);
if(mInputDevice->isKeyDown(Ogre::KC_RIGHT))
mControlNode->translate(MoveFactor, 0.0, 0.0);
if(mInputDevice->isKeyDown(Ogre::KC_F))
{
while (mInputDevice->isKeyDown(Ogre::KC_F))
mInputDevice->capture();
if (mbFirstPerson)
{
// third person
mCameraNode->setPosition( Vector3( 0, 50, -200) );
mbFirstPerson = false;
}
else
{
// first person
mCameraNode->setPosition( Vector3( 0, 5, 40) );
mbFirstPerson = true;
};
};
if (mInputDevice->isKeyDown( KC_ESCAPE))
{
return false;
}
return true;
}Code: Select all
#pragma once
#include "c:\cpp\ogrenew\samples\common\include\exampleframelistener.h"
class SpaceFrameListener : public ExampleFrameListener
{
protected:
SceneNode* mControlNode;
SceneNode* mShipNode;
SceneNode* mCameraNode;
bool mbFirstPerson;
public:
SpaceFrameListener(RenderWindow* win, Camera* cam,
SceneNode* controlNode,
SceneNode* shipNode,
SceneNode* cameraNode);
bool frameStarted(const FrameEvent& evt);
};c:\cpp\ogrenew\Samples\Space3\SpaceFrameListener.cpp(7): error C2512: 'ExampleFrameListener' : no appropriate default constructor available
