所以我想知道如何根据我按下/按下的键改变我创建的角色图像?
当按下"d"(或任何一个按键)时,我最终会有一个行走动画,但是当刚刚按下"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
Run Code Online (Sandbox Code Playgroud)