fix: scene manager rendering
This commit is contained in:
parent
72496226d8
commit
7f32a1d51b
@ -26,14 +26,30 @@ public:
|
|||||||
|
|
||||||
void UpdateActiveScene() {
|
void UpdateActiveScene() {
|
||||||
if (activeScene != entt::null) {
|
if (activeScene != entt::null) {
|
||||||
|
// Iterate over entities in the active scene that have an InputComponent
|
||||||
|
auto view = registry.view<InputComponent>();
|
||||||
|
for (auto entity : view) {
|
||||||
|
auto& inputComponent = view.get<InputComponent>(entity);
|
||||||
|
inputComponent.Update(); // This will call the input logic
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderActiveScene() {
|
void RenderActiveScene() {
|
||||||
if (activeScene != entt::null) {
|
if (activeScene != entt::null) {
|
||||||
|
// Iterate over entities in the active scene that have both SpriteComponent and TransformComponent
|
||||||
|
auto view = registry.view<SpriteComponent, TransformComponent>();
|
||||||
|
for (auto entity : view) {
|
||||||
|
auto& sprite = view.get<SpriteComponent>(entity);
|
||||||
|
auto& transform = view.get<TransformComponent>(entity);
|
||||||
|
|
||||||
|
// Render the sprite at the position defined by the TransformComponent
|
||||||
|
sprite.Render(transform);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
entt::registry& registry;
|
entt::registry& registry;
|
||||||
entt::entity activeScene;
|
entt::entity activeScene;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user