Difference between revisions of "love.keyboard.setKeyRepeat"
m (remove .lua from require) |
|||
Line 14: | Line 14: | ||
<source lang="lua"> | <source lang="lua"> | ||
function love.load() | function love.load() | ||
− | require("AnAL | + | require("AnAL") |
-- Load the animation source. | -- Load the animation source. | ||
imgl = love.graphics.newImage("walkl.png") | imgl = love.graphics.newImage("walkl.png") |
Revision as of 21:20, 31 July 2011
Enables key repeating and sets the delay and interval.
Contents
Function
Synopsis
love.keyboard.setKeyRepeat( delay, Interval )
Arguments
number delay
- The amount of time before repeating the key (in milliseconds). 0 disables key repeat.
number Interval
- The amount of time between repeats (in milliseconds)
Returns
Nothing.
Examples
Press key to continue moving left or right
function love.load()
require("AnAL")
-- Load the animation source.
imgl = love.graphics.newImage("walkl.png")
imgr = love.graphics.newImage("walkr.png")
imgsl = love.graphics.newImage("stopl.png")
imgsr = love.graphics.newImage("stopr.png")
-- Create animation.
anim = newAnimation(imgsl, 32, 48, 0.1, 0)
animX = 100
animY = 100
-- Interval value = Animation's Delay time * The number of Animation's frame
-- 100 ms * 2 frame = 200 ms (Interval)
love.keyboard.setKeyRepeat(10, 200)
end
function love.update(dt)
-- Updates the animation. (Enables frame changes)
anim:update(dt)
end
function love.draw()
-- Draw the animation at (100, 100).
anim:draw(animX , animY)
end
function love.keypressed(key,unicode)
if key == "left" then
anim = newAnimation(imgl,32,48,0.1,0)
anim:setMode ("once")
animX = animX - 10
elseif key == "right" then
anim = newAnimation(imgr, 32, 48, 0.1, 0)
animX = animX + 10
anim:setMode ("once")
end
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