Take a look at the following code:
--Retrieve mouse coordinates
local mousePos = App.window:GetMousePosition()
--Check if the mouse.x is higher then the x position of the start text AND lower then the x position of the text end x.
-- this also needs to be done for y axis
if mousePos.x > button1.x and mousePos.x < (button1.x + button1Width) then
System:Print("the position of the mouse is within the button ")
end
This image represent the code above.
Since you want to check if the mouse is inside the button boundry, we have to perform these steps every frame.
So the code needs to be placed either in UpdateWorld or in PostRender. For instance
function Script:PostRender(context)
local mousePos = App.window:GetMousePosition()
if mousePos.x > 460 and mousePos.x < (460 + 100) then
System:Print("the position of the mouse is within the button ")
end
App.context:SetColor(255, 255, 255)
App.context:SetBlendMode(Blend.Alpha)
App.context:DrawText("Start", 460, 280)
App.context:SetBlendMode(Blend.Solid)
end