MouseHit

This function can be used to tell if a mouse button has been pressed since the last time it was tested.

Syntax

Parameters

Returns

Returns true if the specified mouse button has been pressed, otherwise false is returned.

Example

mousehits = 0 
--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
camera:Move(0,0,-3)
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

model = Model:Box()
model:SetColor(0.0,0.0,1.0)

while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end

Time:Update()
world:Update()
world:Render()

--Press the space key to see the result
if (window:MouseHit(Key.LButton)) then mousehits = mousehits + 1 end
context:SetBlendMode(Blend.Alpha)
context:DrawText("Mouse key hits: "..mousehits,2,2)
context:SetBlendMode(Blend.Solid)
context:Sync(false)

end