love2d创建类
-- TextButton.lua local TextButton = { text="", x=0, y=0, width=0, height=0 } TextButton.__index = TextButton
function TextButton:new(text, x, y, width, height)
local obj = {
text = text,
x = x,
y = y,
width = width,
height = height
}
setmetatable(obj, self)
return obj
end
return TextButton
-- main.lua local TextButton = require "TextButton" function love.load() local a = TextButton:new("INS", 14*2, y , 70, 27) end
浙公网安备 33010602011771号