Hi all

I'm having a List of Entity's here which I would like to traverse. I want to call the function DisplayEntity for every node. Here's the catch: I have expanded the Entity class (same name different namespace) to have SDL data and methods. So basicly what I'm trying to do is:

1. If the element in list is of type ark::Entity >> do nothing.
2. If the element in list is of type sdl_ark::Entity >> call the function displayEntity.

using namespace sdl_ark;

void Game::displayEntitys(){
	
	std::list<ark::Entity*>::iterator it;
	
	
	for (it = fEntityList.begin(); it != fEntityList.end(); it++){
		sdl_ark::Entity sdlEntity;
		(*it) = dynamic_cast<ark::Entity*> (&sdlEntity);
		(*it)->displayEntity(fScreen);
	}
}

This is the error I get.

77: error: 'class ark::Entity' has no member named 'displayEntity'


If you need anymore info, please do tell me. Thanks for taking a look.

Recommended Answers

All 2 Replies

Easy fix, is the have a default do-nothing displayEntity for ark::Entity. Alternative is to rethink your design. It looks like your design went bad somewhere, if your left to do the above hack.

The easy fix isn't possible because of the fact that I can't have any SDL in my ark::Entity. I have to keep the logic and graphical implementation seperated.

I just want one list with Entity's I can traverse. Both logical and graphical functions have to be called on every Entity. I don't really see another way to do it. Any suggestions?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.