Difference between revisions of "SpriteBatch:flush"
m |
m |
||
Line 4: | Line 4: | ||
Normally it isn't necessary to call this method as love.graphics.draw(spritebatch, ...) will do it automatically if needed, but explicitly using [[SpriteBatch:flush]] gives more control over when the work happens. | Normally it isn't necessary to call this method as love.graphics.draw(spritebatch, ...) will do it automatically if needed, but explicitly using [[SpriteBatch:flush]] gives more control over when the work happens. | ||
− | If this method is used, it generally shouldn't be called more than once between love.graphics.draw(spritebatch, ...) calls. | + | If this method is used, it generally shouldn't be called more than once (at most) between love.graphics.draw(spritebatch, ...) calls. |
== Function == | == Function == |
Revision as of 00:24, 29 August 2014
Available since LÖVE 0.9.2 |
This function is not supported in earlier versions. |
Immediately sends all new and modified sprite data in the batch to the graphics card.
Normally it isn't necessary to call this method as love.graphics.draw(spritebatch, ...) will do it automatically if needed, but explicitly using SpriteBatch:flush gives more control over when the work happens.
If this method is used, it generally shouldn't be called more than once (at most) between love.graphics.draw(spritebatch, ...) calls.
Contents
Function
Synopsis
SpriteBatch:flush( )
Arguments
None.
Returns
Nothing.
Examples
Initialize a static spritebatch with sprites and immediately send the data to the graphics card
function love.load()
image = love.graphics.newImage("tile.png")
spritebatch = love.graphics.newSpriteBatch(image, 25 * 25, "static")
for y = 1, 25 do
for x = 1, 25 do
spritebatch:add((x - 1) * 100, (y - 1) * 100)
end
end
-- If we call SpriteBatch:flush now then it won't be called internally when the SpriteBatch is drawn for the first time.
-- In other words, we're choosing to do the work in love.load instead of the first love.draw.
spritebatch:flush()
end
function love.draw()
love.graphics.draw(spritebatch, 0, 0)
end
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info