fix camera coords example (thanks dreadkillz)

This commit is contained in:
Matthias Richter 2012-06-12 13:03:45 +02:00
parent 4e9debb372
commit c50a4e09ca
2 changed files with 2 additions and 2 deletions

View File

@ -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())
]===]
},

View File

@ -345,7 +345,7 @@ cam:detach()</code></pre></p><div class="arguments">Parameters:<dl><dt>function
draw_hud()
end</code></pre></div></div><a name="Camera-camera:worldCoords" id="Camera-camera:worldCoords"></a><a name="Camera-camera:cameraCoords" id="Camera-camera:cameraCoords"></a><div class="ref-block"><h4>function <span class="name">camera:worldCoords</span><span class="arglist">(x, y)</span><a class="top" href="#Camera">^ top</a></h4><h4>function <span class="name">camera:cameraCoords</span><span class="arglist">(x, y)</span><a class="top" href="#Camera">^ top</a></h4><p>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 <em>world coordinates</em>, the second one <em>camera coordinates</em>. 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.</p><p>These two functions convert a point between these two coordinate systems.</p><div class="arguments">Parameters:<dl><dt>numbers <code>x, y</code></dt><dd>Point to transform.</dd></dl></div><div class="returns">Returns:<dl><dt>numbers</dt><dd>Transformed point.</dd></dl></div><div class="example">Example:<pre><code class="lua">x,y = camera:worldCoords(love.mouse.getPosition())
selectedUnit:plotPath(x,y)
</code></pre><pre><code class="lua">x,y = cam:toCameraCoords(player.pos)
</code></pre><pre><code class="lua">x,y = cam:cameraCoords(player.pos)
love.graphics.line(x, y, love.mouse.getPosition())
</code></pre></div></div><a name="Camera-camera:mousepos" id="Camera-camera:mousepos"></a><div class="ref-block"><h4>function <span class="name">camera:mousepos</span><span class="arglist">()</span><a class="top" href="#Camera">^ top</a></h4><p>Shortcut to <code class="lua">camera:worldCoords(love.mouse.getPosition())</code>.</p><div class="arguments">Parameters:<dl><dt>None</dt></dl></div><div class="returns">Returns:<dl><dt>numbers</dt><dd>Mouse position in world coordinates.</dd></dl></div><div class="example">Example:<pre><code class="lua">x,y = camera:mousepos()
selectedUnit:plotPath(x,y)