Jump to content

I have problems


ErhanK
 Share

Recommended Posts

Hi, I have a few questions. I am using C ++.

1) For example, I have a derived entity class, and I have a derived actor class attached to this class. Pickinfo gives me an entity when the bullet hits this class. I can also access the atached actor with pickinfo.entity.GetActor (). But since it doesn't give me the class and actor I've derived, I can't call the giveHurt () function in them.

2) In the documentation, the ForEachEntityInAABBDo function can be called in main (). There is no problem. But I can't call the callback function of a class. Should I use a function pointer?

world-> ForEachEntityInAABBDo(aabb, &MyClass::Callback, v); it does not work. Also I cannot call the callback function with a string.

I need to solve these problems so that I can continue to improve my game. I can't get enough help from the forum. I will be glad if you help me.

Link to comment
Share on other sites

You can get the actor object, and then you need to cast that actor to whatever class it is:
https://en.cppreference.com/w/cpp/language/dynamic_cast

The function has an extra object you can supply:
https://www.leadwerks.com/learn?page=API-Reference_Object_World_ForEachEntityInAABBDo

Your callback function can call a function on the object, like this:

void Callback(Entity* entity, Object* extra)
{
	MyObject* o = dynamic_cast<MyObject*>(extra);
	o->DoSomething();
}

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...