添加场景的组件动态添加删除功能

This commit is contained in:
2025-05-31 13:30:54 +08:00
parent 31c77dcb5e
commit fdd13a8726
20 changed files with 340 additions and 59 deletions

View File

@ -57,16 +57,16 @@ namespace Hazel
public:
void OnUpdate(const TimeStep ts)
{
auto& transform = GetComponent<TransformComponent>().Transform;
auto& translation = GetComponent<TransformComponent>().Translation;
static const auto state = SDL_GetKeyboardState(nullptr);
if (state[SDL_SCANCODE_A])
transform[3][0] -= ts * speed;
translation.x -= ts * speed;
if (state[SDL_SCANCODE_D])
transform[3][0] += ts * speed;
translation.x += ts * speed;
if (state[SDL_SCANCODE_W])
transform[3][1] += ts * speed;
translation.y += ts * speed;
if (state[SDL_SCANCODE_S])
transform[3][1] -= ts * speed;
translation.y -= ts * speed;
}
private:
float speed = 2.0f;
@ -175,6 +175,8 @@ namespace Hazel
// Submit the DockSpace
ImGuiIO& io = ImGui::GetIO();
ImGuiStyle& style = ImGui::GetStyle();
style.WindowMinSize.x = 350.0f;
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
{
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");