love.update (한국어)
매 프레임마다 게임의 상태를 갱신할 때 쓰이는 콜백 함수입니다.
함수
형식
love.update( dt )
매개 변수
number (한국어) dt
- 마지막 love.update로부터 경과된 시간.
리턴값
없음.
예제
Run a function called think inside a table called npc once per second.
dtotal = 0 -- this keeps track of how much time has passed
function love.update(dt)
dtotal = dtotal + dt -- we add the time passed since the last update, probably a very small number like 0.01
if dtotal >= 1 then
dtotal = dtotal - 1 -- reduce our timer by a second, but don't discard the change... what if our framerate is 2/3 of a second?
npc.think()
end
end
Change a variable var at a constant rate (+/- 3 per second in this example).
var = 10 -- arbitrary starting value
rate = 3 -- change to change the rate at which the var is changed
function love.update(dt)
if love.keyboard.isDown("down") then -- reduce the value
var = var - (dt * rate)
end
if love.keyboard.isDown("up") then -- increase the value
var = var + (dt * rate)
end
end
See Also
다른 언어
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