From c50a4e09ca4fc047daadcde721b6c9e1a68ef781 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Tue, 12 Jun 2012 13:03:45 +0200 Subject: [PATCH] fix camera coords example (thanks dreadkillz) --- doc.lua | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc.lua b/doc.lua index 572bb49..d03616b 100644 --- a/doc.lua +++ b/doc.lua @@ -1536,7 +1536,7 @@ end]===] x,y = camera:worldCoords(love.mouse.getPosition()) selectedUnit:plotPath(x,y) ]===], [===[ -x,y = cam:toCameraCoords(player.pos) +x,y = cam:cameraCoords(player.pos) love.graphics.line(x, y, love.mouse.getPosition()) ]===] }, diff --git a/index.html b/index.html index 916d952..0f40bea 100644 --- a/index.html +++ b/index.html @@ -345,7 +345,7 @@ cam:detach()

Parameters:
function draw_hud() end

function camera:worldCoords(x, y)^ top

function camera:cameraCoords(x, y)^ top

Because a camera has a point it looks at, a rotation and a zoom factor, it defines a coordinate system. A point now has two sets of coordinates: One defines where the point is to be found in the game world, and the other describes the position on the computer screen. The first set of coordinates is called world coordinates, the second one camera coordinates. Sometimes it is needed to convert between the two coordinate systems, for example to get the position of a mouse click in the game world in a strategy game, or to see if an object is visible on the screen.

These two functions convert a point between these two coordinate systems.

Parameters:
numbers x, y
Point to transform.
Returns:
numbers
Transformed point.
Example:
x,y = camera:worldCoords(love.mouse.getPosition())
 selectedUnit:plotPath(x,y)
-
x,y = cam:toCameraCoords(player.pos)
+
x,y = cam:cameraCoords(player.pos)
 love.graphics.line(x, y, love.mouse.getPosition())
 

function camera:mousepos()^ top

Shortcut to camera:worldCoords(love.mouse.getPosition()).

Parameters:
None
Returns:
numbers
Mouse position in world coordinates.
Example:
x,y = camera:mousepos()
 selectedUnit:plotPath(x,y)