Difference between revisions of "love.event.push"

(Added updated variant.)
(Updated example.)
Line 28: Line 28:
 
Nothing.
 
Nothing.
 
== Examples ==
 
== Examples ==
=== Quitting an app ===
+
=== Quitting a game in 0.8.0 ===
 
<source lang="lua">
 
<source lang="lua">
 
function love.keypressed(k)
 
function love.keypressed(k)
 
if k == 'escape' then
 
if k == 'escape' then
love.event.push('q') -- quit the game
+
love.event.push('quit') -- Quit the game.
 +
end
 +
end
 +
</source>
 +
=== Quitting a game in 0.7.2 ===
 +
<source lang="lua">
 +
function love.keypressed(k)
 +
if k == 'escape' then
 +
love.event.push('q') -- Quit the game.
 
end
 
end
 
end
 
end

Revision as of 22:10, 8 April 2012

Adds an event to the event queue.

Function

Available since LÖVE 0.8.0
This variant is not supported in earlier versions.

Synopsis

love.event.push( event, var1, var2, var3, var4 )

Arguments

Event event
The name of the event.
mixed var1 (nil)
First event argument.
mixed var2 (nil)
Second event argument.
mixed var3 (nil)
Third event argument.
mixed var4 (nil)
Fourth event argument.

Returns

Nothing.

Function

Removed in LÖVE 0.7.2
This variant is not supported in that and later versions.

Synopsis

love.event.push( e, a, b, c )

Arguments

Event e
The type of event.
mixed a (nil)
First event argument.
mixed b (nil)
Second event argument.
mixed c (nil)
Third event argument.

Returns

Nothing.

Examples

Quitting a game in 0.8.0

function love.keypressed(k)
	if k == 'escape' then
		love.event.push('quit') -- Quit the game.
	end	
end

Quitting a game in 0.7.2

function love.keypressed(k)
	if k == 'escape' then
		love.event.push('q') -- Quit the game.
	end	
end

See Also


Other Languages