Hi, all. I'm have a class EnemyController with a function Spawn(...) that instantiates a new object of the appropriate type. I want to call Spawn from somewhere like my TileMap class to create a new Enemy in my tile collision method. Here's what I have so far...
class EnemyController
{
public:
EnemyController() {}
~EnemyController() {}
static void Spawn( int x, int y, EnemyType type );
virtual void OnUpdate( Camera& cam )
{
int index = 0;
for( auto i= EnemyList.begin(), end = EnemyList.end(); i != end; i++ )
{
EnemyList.at( index )->GetState().OnUpdate();
EnemyList.at( index++ )->Draw( cam );
}
}
public:
static std::deque< EnemySprite* > EnemyList;
};
// Spawn(...) defined in the .cpp file
class TileMap
{
public:
TileMap( const char* map, int mapWidth, int mapHeight, int tileWidth, int tileHeight );
~TileMap();
void DoCollision( Sprite& s );
//stuff
private:
//stuff
static EnemyController* eCon;
};
// In DoCollision(...)
if( condition )
{
TileMap::eCon->Spawn( enemytype );
}
I keep getting "Unresolved External" link errors. I think I'm confused about static? I want the EnemyController class to spawn, keep track of, and manage all enemies, but I want to Spawn from differnt trigger points (hitting a certain tile, etc.).