Games104作业四的基础部分和提高部分,主要完成了以下两个内容:
- 在 motor.h 中增加 control_jump_with_height 和 m_jump_speed 两个属性,用于选择性地使用玩家跳跃时的初速度来控制玩家向上跳跃的高度,同时修改 editor_ui.cpp,确保增加的属性可以正确的显示在界面上;
- 修改 MotorComponent::calculatedDesiredVerticalMoveSpeed 函数,给跳跃的控制增加使用跳跃初速度的选项;
首先在 motor.h 中增加两个属性定义,如下图所示:

调试程序后,发现 bool 值并不能在 UI 上显示出来,查看 editor.cpp 发现其中并没有实现对 bool 类型的反射支持,仿照其他数据类型的写法,在 EditorUI::EditorUI() 增加以下代码实现对 bool 类型的反射支持。
// 增加对布尔类型的处理
m_editor_ui_creator["bool"] = [this](const std::string& name, void* value_ptr) -> void {
if (g_node_depth == -1)
{
std::string label = "##" + name;
ImGui::Text("%s", name.c_str());
ImGui::SameLine();
ImGui::Checkbox(label.c_str(), static_cast<bool*>(value_ptr));
}
else
{

最低0.47元/天 解锁文章
1060

被折叠的 条评论
为什么被折叠?



