-
Notifications
You must be signed in to change notification settings - Fork 15
(API) Image Button
The image button object is pretty much the same as the button object except it can have an image.
function love.load()
loveframes = require("loveframes")
local imagebutton = loveframes.Create("imagebutton")
imagebutton:SetImage("magic.jpg")
imagebutton:SizeToImage()
imagebutton:SetText("CLICK THE IMAGE")
imagebutton:CenterWithinArea(0, 0, love.graphics.getDimensions())
end
function love.update(dt)
loveframes.update(dt)
end
function love.draw()
loveframes.draw()
end
function love.mousepressed(x, y, button)
loveframes.mousepressed(x, y, button)
end
function love.mousereleased(x, y, button)
loveframes.mousereleased(x, y, button)
end
Called every time the object is clicked
Arguments passed: self [object], mouse x [number], mouse y [number]
local imagebutton = loveframes.Create("imagebutton")
imagebutton.OnClick = function(object)
print("The image button was clicked!")
end
Sets the object's text
object:SetText(text[string])
Gets the object's text
Returns 1 value: text [string]
local text = object:GetText()
Sets whether or not the object is clickable
object:SetClickable(clickable[bool])
Gets whether or not the object is clickable
Returns 1 value: clickable [boolean]
local clickable = object:GetClickable()
Sets whether or not the object is enabled
object:SetEnabled(enabled[bool])
Gets whether or not the object is enabled
Returns 1 value: enabled [bool]
local enabled = object:GetEnabled()
Sets the object's font
object:SetFont(font[font])
Gets the object's font
Returns 1 value: font [font]
local font = object:GetFont()
Sets the object's image
imagebutton:SetImage(image[string (imagepath) or imageobject])
Gets the object's image
Returns 1 value: image [image]
local image = imagebutton:GetImage()
Makes the object the size of it's image
imagebutton:SizeToImage()
Gets the object's image size
Returns 2 values: imagewidth [number], imageheight [number]
local imagewidth, imageheight = object:GetImageSize()
Gets the object's image width
Returns 1 value: imagewidth [number]
local imagewidth = object:GetImageWidth()
Gets the object's image height
Returns 1 value: imageheight [number]
local imageheight = object:GetImageHeight()