Difference between revisions of "love.graphics.getStackDepth"

m (0.11.0 -> 11.0)
(Added example.)
 
Line 11: Line 11:
 
=== Returns ===
 
=== Returns ===
 
{{param|number|depth|The current depth of the transform and state love.graphics stack.}}
 
{{param|number|depth|The current depth of the transform and state love.graphics stack.}}
 +
 +
== Examples ==
 +
<source lang="lua">
 +
local function popWholeStack()
 +
for i = 1, love.graphics.getStackDepth() do
 +
love.graphics.pop()
 +
end
 +
end
 +
 +
function love.draw()
 +
love.graphics.push() ; love.graphics.push() ; love.graphics.push()
 +
popWholeStack()
 +
end
 +
</source>
  
 
== See Also ==
 
== See Also ==
Line 16: Line 30:
 
* [[love.graphics.push]]
 
* [[love.graphics.push]]
 
* [[love.graphics.pop]]
 
* [[love.graphics.pop]]
 +
 +
== Other Languages ==
 +
{{i18n|love.graphics.getStackDepth}}
 +
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{#set:Sub-Category=State}}
 
{{#set:Sub-Category=State}}
 
{{#set:Description=Gets the current depth of the transform / state stack (the number of [[love.graphics.push|pushes]] without corresponding [[love.graphics.pop|pops]]).}}
 
{{#set:Description=Gets the current depth of the transform / state stack (the number of [[love.graphics.push|pushes]] without corresponding [[love.graphics.pop|pops]]).}}
== Other Languages ==
 
{{i18n|love.graphics.getStackDepth}}
 

Latest revision as of 00:37, 1 September 2022

Available since LÖVE 11.0
This function is not supported in earlier versions.

Gets the current depth of the transform / state stack (the number of pushes without corresponding pops).

Function

Synopsis

depth = love.graphics.getStackDepth( )

Arguments

None.

Returns

number depth
The current depth of the transform and state love.graphics stack.

Examples

local function popWholeStack()
	for i = 1, love.graphics.getStackDepth() do
		love.graphics.pop()
	end
end

function love.draw()
	love.graphics.push() ; love.graphics.push() ; love.graphics.push()
	popWholeStack()
end

See Also

Other Languages