代码拉取完成,页面将自动刷新
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。