Well here's the thing. I'm using spawner to spawn enemies. Everything was fine with one, I have just simple code but now I need three enemies so I made enemy object to handle it.
I'm listening to CREATE handler and then I test if name of object is correct (enemy object name) and then do some action. Problem is, that orxObject_GetName returns name only of first object created by spawner (even if spawner is now able to create object of one type only because I don't have other two created in config), then it returns nothing and I can't do what I need if I don't know object's name.
I've already updated ORX to newest SVN version, but problem is still there.
I was using orxObject_GetName in my old simplecoded version too and everything was OK so I don't know where problem is.
void orxFASTCALL Game::Create(const orxEVENT* currentEvent){
orxOBJECT *object = (orxOBJECT*)currentEvent->hSender;
orxLOG("Create");
if (object != orxNULL) {
const orxCHAR *name = orxObject_GetName(object);
orxLOG("Name is: %s", name);
...
...
...
I tried to connect my Create function to SPAWN handler (no need to check name of created object), but it always crashed when I used object
Comments
orxOBJECT *object = orxOBJECT(currentEvent->hSender);
if (object == 0){
return;
}
are you sure you define the macro __orxDEBUG__ when using orxd lib, while remove the macro when using orx lib.
I'm just probably listening to wrong handler or something.
That being said, I'm afraid I need more details about the code/config than just the example you pasted here.
Also note that the hSender for the orxEVENT_TYPE_SPAWNER/orxSPAWNER_EVENT_CREATE event is an orxOBJECT, but for all other orxEVENT_TYPE_SPAWNER, it's an orxSPAWNER.