summaryrefslogtreecommitdiff
path: root/examples/raygui_custom/spriteButton.lua
diff options
context:
space:
mode:
authorjussi2024-01-05 23:15:22 +0200
committerjussi2024-01-05 23:15:22 +0200
commit863f596b76043ec374fafa38f14cdc4a97d0b267 (patch)
tree9fbf9c424e2a1644b52b795715cdb60b6ed04eae /examples/raygui_custom/spriteButton.lua
parent70a2bcba18aa9855380c132f89e26b61bfd2cb40 (diff)
downloadreilua-enhanced-863f596b76043ec374fafa38f14cdc4a97d0b267.tar.gz
reilua-enhanced-863f596b76043ec374fafa38f14cdc4a97d0b267.tar.bz2
reilua-enhanced-863f596b76043ec374fafa38f14cdc4a97d0b267.zip
Raygui lib enhancements and Raygui lib extensions example.
Diffstat (limited to 'examples/raygui_custom/spriteButton.lua')
-rw-r--r--examples/raygui_custom/spriteButton.lua54
1 files changed, 0 insertions, 54 deletions
diff --git a/examples/raygui_custom/spriteButton.lua b/examples/raygui_custom/spriteButton.lua
deleted file mode 100644
index b37b208..0000000
--- a/examples/raygui_custom/spriteButton.lua
+++ /dev/null
@@ -1,54 +0,0 @@
---- Button control
-local SpriteButton = {}
-SpriteButton.__index = SpriteButton
-
-function SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, callback )
- local object = setmetatable( {}, self )
- object._parent = nil
-
- object.bounds = bounds:clone()
- object.text = text
- object.buttonTexture = texture
- object.nPatchNormal = nPatchNormal
- object.nPatchPressed = nPatchPressed
- object.callback = callback
-
- object.visible = true
- object.disabled = false
-
- return object
-end
-
-function SpriteButton:process()
- return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
-end
-
-function SpriteButton:draw()
- if RL.IsMouseButtonDown( RL.MOUSE_BUTTON_LEFT ) and self:process() then
- RL.DrawTextureNPatchRepeat( self.buttonTexture, self.nPatchPressed, self.bounds, { 0, 0 }, 0.0, RL.WHITE )
- else
- RL.DrawTextureNPatchRepeat( self.buttonTexture, self.nPatchNormal, self.bounds, { 0, 0 }, 0.0, RL.WHITE )
- end
-
- local result = RL.GuiLabelButton( self.bounds, self.text )
-
- if result == 1 then
- if self.callback ~= nil then
- self.callback( self )
- end
- end
-
-end
-
-function SpriteButton:setPosition( pos )
- self.bounds.x = pos.x
- self.bounds.y = pos.y
-end
-
-function SpriteButton:register( gui )
- function gui:SpriteButton( bounds, text, texture, nPatchNormal, nPatchPressed, callback )
- return self:addElement( SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, callback ) )
- end
-end
-
-return SpriteButton