我想知道如何根据我按下/正在按下的键来改变所创建的角色的图像?
当按下“d”(或任何wasd键)时,我的最终目标是出现行走动画,但当刚刚按下“d”键时,他会站在原地。所有图像都已经创建好了。
我尝试过这个,但它没有奏效:
function love.load()
if love.keyboard.isDown("a") then
hero = love.graphics.newImage("/hero/11.png")
elseif love.keyboard.isDown("d") then
hero = love.graphics.newImage("/hero/5.png")
elseif love.keyboard.isDown("s") then
hero = love.graphics.newImage("/hero/fstand.png")
elseif love.keyboard.isDown("w") then
hero = love.graphics.newImage("/hero/1.png")
end
function love.draw()
love.graphics.draw(background)
love.graphics.draw(hero, x, y)
end