Available since LÖVE 11.0 |
This function is not supported in earlier versions. |
Adds a sprite to a batch created with an Array Texture.
Adds a layer of the SpriteBatch's Array Texture.
spriteindex = SpriteBatch:addLayer( layerindex, x, y, r, sx, sy, ox, oy, kx, ky )
number layerindex
number x (0)
number y (0)
number r (0)
number sx (1)
number sy (sx)
number ox (0)
number oy (0)
number kx (0)
number ky (0)
number spriteindex
Adds a layer of the SpriteBatch's Array Texture using the specified Quad.
spriteindex = SpriteBatch:addLayer( layerindex, quad, x, y, r, sx, sy, ox, oy, kx, ky )
number layerindex
Quad quad
number x (0)
number y (0)
number r (0)
number sx (1)
number sy (sx)
number ox (0)
number oy (0)
number kx (0)
number ky (0)
number spriteindex
The specified layer index overrides any layer index set on the Quad via Quad:setLayer.
Adds a layer of the SpriteBatch's Array Texture using the specified Transform.
spriteindex = SpriteBatch:addLayer( layerindex, transform )
number layerindex
Transform transform
number spriteindex
Adds a layer of the SpriteBatch's Array Texture using the specified Quad and Transform.
spriteindex = SpriteBatch:addLayer( layerindex, quad, transform )
number layerindex
Quad quad
Transform transform
number spriteindex
The specified layer index overrides any layer index set on the Quad via Quad:setLayer.
In order to use an Array Texture or other non-2D texture types as the main texture in a custom Shader, the void effect() variant must be used in the pixel shader, and MainTex must be declared as an ArrayImage or sampler2DArray like so: uniform ArrayImage MainTex;
.
function love.load() local sprites = {"sprite1.png", "sprite2.png"} image = love.graphics.newArrayImage(sprites) batch = love.graphics.newSpriteBatch(image) batch:addLayer(1, 50, 50) batch:addLayer(2, 250, 50) end function love.draw() love.graphics.draw(batch) end
shader = love.graphics.newShader[[ uniform ArrayImage MainTex; void effect() { // Texel uses a third component of the texture coordinate for the layer index, when an Array Texture is passed in. // love sets up the texture coordinates to contain the layer index specified in love.graphics.drawLayer, when // rendering the Array Texture. love_PixelColor = Texel(MainTex, VaryingTexCoord.xyz) * VaryingColor; } ]] function love.load() local sprites = {"sprite1.png", "sprite2.png"} image = love.graphics.newArrayImage(sprites) batch = love.graphics.newSpriteBatch(image) batch:addLayer(1, 50, 50) batch:addLayer(2, 250, 50) end function love.draw() love.graphics.setShader(shader) love.graphics.draw(batch) end