ErhanK Posted April 1, 2019 Share Posted April 1, 2019 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. Quote Link to comment Share on other sites More sharing options...
Josh Posted April 1, 2019 Share Posted April 1, 2019 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(); } Quote 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 More sharing options...
ErhanK Posted April 1, 2019 Author Share Posted April 1, 2019 the actual problem is here. i cant call this function.. both of them in the same class. Thanks for other reply. Quote Link to comment Share on other sites More sharing options...
Josh Posted April 1, 2019 Share Posted April 1, 2019 Is MonsterBase::Callback() a static function? Quote 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 More sharing options...
ErhanK Posted April 1, 2019 Author Share Posted April 1, 2019 Thank you?! useful information for me. it's working Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.