How can I make this walking animation work?
Posted: Wed Jul 04, 2012 11:58 pm
Okay, I have 4 walking animation pictures, 2 facing left, 2 facing right. Their names are:
- playerwalk1.png
- playerwalk2.png
- playerwalk1flipped.png
- playerwalk2flipped.png
How can I make it so when I hold down "D" it switches between "playerwalk1flipped.png" and "playerwalk2flipped.png" at 0.5 second intervals, and when I press "A" it switches between "playerwalk1.png" and "playerwalk2.png" at 0.5 second intervals?
This is the code I have so far:
- playerwalk1.png
- playerwalk2.png
- playerwalk1flipped.png
- playerwalk2flipped.png
How can I make it so when I hold down "D" it switches between "playerwalk1flipped.png" and "playerwalk2flipped.png" at 0.5 second intervals, and when I press "A" it switches between "playerwalk1.png" and "playerwalk2.png" at 0.5 second intervals?
This is the code I have so far:
Code: Select all
function love.keyboard.isDown(key,dt)
if key == "d" then
player.texture = love.graphics.newImage("images/playerwalk1flipped.png")
if key == "a" then
player.texture = love.graphics.newImage("images/playerwalk1.png")