C++ still hard for me, and I can not solve the following problem
I want to complicate the class Scene:
class Level : public Scene
{
URHO3D_OBJECT(Level, Scene);
public:
Level(Context* context);
Camera* camera_ = nullptr;
void Show();
void HandleUpdate(StringHash eventType, VariantMap& eventData);
};
Level::Level(Context* context) : Scene(context)
{
SubscribeToEvent(E_UPDATE, URHO3D_HANDLER(Level, HandleUpdate));
}
void Level::Show()
{
if (!camera_)
camera_ = GetChild("Camera")->GetComponent<Camera>();
Renderer* renderer = GetSubsystem<Renderer>();
Viewport* viewport = renderer->GetViewport(0);
viewport->SetScene(this);
viewport->SetCamera(camera_);
}
void Level::HandleUpdate(StringHash eventType, VariantMap& eventData)
{
// some actions
}
And using it in game:
ResourceCache* cache = GetSubsystem<ResourceCache>();
Level* level1 = new Level(context_);
scene->LoadXML(*cache->GetFile("Scenes/1.xml"));
The level is loaded from a file, but the physics does not work. As far as I understand, the reason for this is the overriding handler of update.
In XNA handlers were determined as protected, and users can call functions of base class, but in Urho3D all private. Any ideas?