Difference between revisions of "love.keyboard.setKeyRepeat"
Poorenglish (talk | contribs) |
m |
||
Line 56: | Line 56: | ||
[[Category:Functions]] | [[Category:Functions]] | ||
{{#set:Description=Enables key repeating and sets the delay and interval.}} | {{#set:Description=Enables key repeating and sets the delay and interval.}} | ||
+ | == Other Languages == | ||
+ | {{i18n|love.keyboard.setKeyRepeat}} |
Revision as of 20:30, 18 November 2010
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.lua")
-- 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