I ran into another problem as I was converting all my code so that it derives off a base class. Basically I made a rigid body that derives from a class box. Now I am trying to make a character class derive from rigid body but I am getting an error I haven't really seen before.
Error 1 error LNK2001: unresolved external symbol "public: virtual void __thiscall Character::Secondary(void)" (?Secondary@Character@@UAEXXZ) Main.obj
here are my two classes:
#include "IncludeAll.h"
#ifndef CHARACATER_H
#define CHARACATER_H
class Character : public RigidBox
{
public:
Character(int Xpos,int Ypos,float SpriteScale,int Box_ID,int Sprite_ID );
void Update();
void Initialize(b2World*);
virtual void Primary();
virtual void Secondary();
virtual void Movement();
protected:
float turnSpeedCapRight;
float turnSpeedCapLeft;
float tCheck;
bool canJump;
bool isJumping;
int maxJump;
int initialJump;
float playerSpeed;
float playerJumpMaxSpeed;
float speedCap;
};
Character::Character (int X,int Y,float SpriteScale,int Box_ID,int Sprite_ID):RigidBox(X,Y,SpriteScale,Box_ID,Sprite_ID)
{
initialJump = -100;
maxJump = -10;
speedCap = scale * .1;
playerSpeed = scale * .09;
turnSpeedCapRight = -10;
turnSpeedCapLeft = 10;
canJump = false;
isJumping = false;
tCheck = 0.0f;
}
void Character::Initialize(b2World* world)
{
RigidBox::Initialize(world);
BoxBodyDef.fixedRotation = true;
}
/////////////////Update the Box and paste the sprite to its position//////////////////////
void Character::Update()
{
RigidBox::Update();
dbText(5,5,dbStr(tCheck));
dbSprite(BoxID+1,position.x,position.y + dbSpriteHeight(BoxID) / 2 + 1,2);
dbSizeSprite(BoxID+1,dbSpriteWidth(BoxID) * 0.7f,dbSpriteHeight(BoxID) * 0.01);
dbOffsetSprite(BoxID+1,dbSpriteWidth(BoxID+1)/2,dbSpriteHeight(BoxID+1)/2);
Movement();
Primary();
dbText(5,15, dbStr(BoxBody->GetLinearVelocity().y));
dbText(5,30, dbStr(BoxBody->GetLinearVelocity().x));
}
that is my character class and I only added in the functions that I actually want to derive from Rigid Box.
Here is the rigid box class:
#include "IncludeAll.h"
#ifndef RIGIDBOX_H
#define RIGIDBOX_H
class RigidBox: public Box
{
public:
RigidBox(int Xpos,int Ypos,float scale,int ID_box,int ID_sprite);
virtual void Initialize(b2World*);
protected:
};
RigidBox::RigidBox (int X,int Y,float SpriteScale,int Box_ID,int Sprite_ID):Box(X,Y,SpriteScale,Box_ID,Sprite_ID)
{
}
void RigidBox::Initialize(b2World* world)
{
Box::Initialize(world);
BoxBodyDef.position.Set(posX /b2PixelRatio, posY /b2PixelRatio);
BoxBody = world->CreateBody(&BoxBodyDef);
BoxShapeDef.SetAsBox((dbSpriteWidth(BoxID)/b2PixelRatio)/2.0f, (dbSpriteHeight(BoxID)/b2PixelRatio)/2.0f);
BoxBody->CreateShape(&BoxShapeDef);
BoxShapeDef.density = 1.0f;
BoxShapeDef.friction = 0.3f;
BoxBody->CreateShape(&BoxShapeDef);
BoxBody->SetMassFromShapes();
}
#endif
So I'm not to sure what I am doing wrong. Anyone see something that I am doing wrong?