Difference between revisions of "Geometry"

m
m
Line 55: Line 55:
 
end
 
end
  
setQuadViewport(myGeometry, 0, 0, 32, 32, myImage:getDimensions())
+
setQuadViewport(myQuad, 0, 0, 32, 32, myImage:getDimensions())
 
</source>
 
</source>
  

Revision as of 23:47, 21 August 2013

Available since LÖVE 0.9.0
This type is not supported in earlier versions.

A polygonal shape with texture coordinate information.

Geometries can be used to select part of a texture to draw. In this way, one large texture atlas can be loaded, and then split up into sub-images.

Geometries replace the old Quad type completely since they can do the same and more.

Constructors

None.

Functions

Object:release Immediately destroys the object's Lua reference. Added since 11.0
Object:type Gets the type of the object as a string.
Object:typeOf Checks whether an object is of a certain type.

Enums

Supertypes

Examples

Emulate 0.8.0's Quad:setViewport

-- Quad:setViewport doesn't exist in 0.9.0+, but we can still create a function which does the same thing.
-- The original image's width and height are needed as well, unlike with 0.8.0's Quad:setViewport.
function setQuadViewport(geometry, x, y, w, h, sw, sh)
	geometry:setVertex(1, 0, 0, x/sw, y/sh)
	geometry:setVertex(2, 0, h, x/sw, (y+h)/sh)
	geometry:setVertex(3, w, h, (x+w)/sw, (y+h)/sh)
	geometry:setVertex(4, w, 0, (x+w)/sw, y/sh)
end

setQuadViewport(myQuad, 0, 0, 32, 32, myImage:getDimensions())

See Also

Other Languages

--@todo: add Concept:Current to stuffs when done adding stuffs.