Game Development Reference
In-Depth Information
love.graphics.setColor(0,0,0,255)
love.graphics.setBackgroundColor(255,255,255,255)
end
function love.draw()
love.graphics.draw(theImage, x, y, theAngle)
end
function love.update(dt)
local mouseX, mouseY = love.mouse.getX(), love.mouse.getY()
theAngle = math.atan2(mouseY - y, mouseX-x)
end
love.mouse.setVisible
theImage = love.graphics.newImage("myImage.png")
crosshair = love.graphics.newImage("crosshair.png")
x = _W/2
y = _H/2
love.graphics.setBackgroundColor(255,255,255,255)
love.mouse.setVisible(false)
end
function love.draw()
love.graphics.draw(theImage, x, y, theAngle)
love.graphics.draw(crosshair, love.mouse.getX(), love.mouse.getY())
end
function love.update(dt)
local mouseX, mouseY = love.mouse.getX(), love.mouse.getY()
theAngle = math.atan2(mouseY - y, mouseX - x)
end
Note When we set the x- and y-coordinates, this is generally the upper-left corner position, so the
image is not exactly centered on the x, y coordinates.
 
Search WWH ::




Custom Search