1 Star 0 Fork 0

火魂/imgui-love2d-win-exe

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.lua 2.93 KB
一键复制 编辑 原始数据 按行查看 历史
火魂 提交于 2021-07-02 11:41 . imgui1
require "imgui"
local showTestWindow = false
local showAnotherWindow = false
local floatValue = 0;
local sliderFloat = { 0.1, 0.5 }
local clearColor = { 0.2, 0.2, 0.2 }
local comboSelection = 1
local textValue = "text"
--
-- LOVE callbacks
--
function love.load(arg)
end
function love.update(dt)
imgui.NewFrame()
end
function love.draw()
-- Menu
if imgui.BeginMainMenuBar() then
if imgui.BeginMenu("File") then
imgui.MenuItem("Test")
imgui.EndMenu()
end
imgui.EndMainMenuBar()
end
-- Debug window
imgui.Text("Hello, world!");
clearColor[1], clearColor[2], clearColor[3] = imgui.ColorEdit3("Clear color", clearColor[1], clearColor[2], clearColor[3]);
-- Sliders
floatValue = imgui.SliderFloat("SliderFloat", floatValue, 0.0, 1.0);
sliderFloat[1], sliderFloat[2] = imgui.SliderFloat2("SliderFloat2", sliderFloat[1], sliderFloat[2], 0.0, 1.0);
-- Combo
comboSelection = imgui.Combo("Combo", comboSelection, { "combo1", "combo2", "combo3", "combo4" }, 4);
-- Windows
if imgui.Button("Test Window") then
showTestWindow = not showTestWindow;
end
if imgui.Button("Another Window") then
showAnotherWindow = not showAnotherWindow;
end
if showAnotherWindow then
imgui.SetNextWindowPos(50, 50, "ImGuiCond_FirstUseEver")
showAnotherWindow = imgui.Begin("Another Window", true, { "ImGuiWindowFlags_AlwaysAutoResize", "ImGuiWindowFlags_NoTitleBar" });
imgui.Text("Hello");
-- Input text
textValue = imgui.InputTextMultiline("InputText", textValue, 200, 300, 200);
imgui.End();
end
if showTestWindow then
showTestWindow = imgui.ShowDemoWindow(true)
end
love.graphics.clear(clearColor[1], clearColor[2], clearColor[3])
imgui.Render();
end
function love.quit()
imgui.ShutDown();
end
--
-- User inputs
--
function love.textinput(t)
imgui.TextInput(t)
if not imgui.GetWantCaptureKeyboard() then
-- Pass event to the game
end
end
function love.keypressed(key)
imgui.KeyPressed(key)
if not imgui.GetWantCaptureKeyboard() then
-- Pass event to the game
end
end
function love.keyreleased(key)
imgui.KeyReleased(key)
if not imgui.GetWantCaptureKeyboard() then
-- Pass event to the game
end
end
function love.mousemoved(x, y)
imgui.MouseMoved(x, y)
if not imgui.GetWantCaptureMouse() then
-- Pass event to the game
end
end
function love.mousepressed(x, y, button)
imgui.MousePressed(button)
if not imgui.GetWantCaptureMouse() then
-- Pass event to the game
end
end
function love.mousereleased(x, y, button)
imgui.MouseReleased(button)
if not imgui.GetWantCaptureMouse() then
-- Pass event to the game
end
end
function love.wheelmoved(x, y)
imgui.WheelMoved(y)
if not imgui.GetWantCaptureMouse() then
-- Pass event to the game
end
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zmwcodediy/imgui-love2d-win-exe.git
git@gitee.com:zmwcodediy/imgui-love2d-win-exe.git
zmwcodediy
imgui-love2d-win-exe
imgui-love2d-win-exe
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385