Hi, im trying to code a charcter that has a walking animation. I'm using the hampster ball tutorial with the AnAL tutorial and it seems to be conflicting, but i don't know of any other way to put an idle or walking animation in the game
this is my main.lua code
require("AnAL")
function love.load()
local bullet = love.graphics.newImage("bullet.png")
anim = newAnimation(bullet, 128,128, 0.1, 0)
x = 50
y = 50
speed = 100
anim:setMode("loop")
end
function love.update(dt)
-- Updates the animation. (Enables frame changes)
anim:update(dt)
if love.keyboard.isDown("d") then
x = x + (speed * dt)
elseif love.keyboard.isDown("a") then
x = x - (speed * dt)
end
if love.keyboard.isDown("s") then
y = y + (speed * dt)
elseif love.keyboard.isDown("w") then
y = y - (speed * dt)
end
end
function love.draw()
love.graphics.draw (bullet, x, y)
end
error
main.lua:30: Incorrect parameter type: expected userdata.
traceback
[C]: in fucntion 'draw'
main.lua:30: in fucntion 'draw'
[C]: in function 'xpcall'
When i did that the animation didn't play it was just the whole image being drawn. The character moves though. is AnAL the only practical way to play animations in love? i though i heard they cut it from love.
function love.load()
animation = {}
animation.frame = 1
animation.frame1 = (some image)
animation.frame2 = (some other image)
animation.frame3 = (yet another image)
animation.image = animation.frame1
end
function love.update(dt)
if animation.frame ==1 then
animation.image = animation.frame1
frame=frame + 1
else if animation.frame == 2 then
frame = frame + 1
animation.image = animation.frame2
else if animation.frame == 3 then
animation.image = animation.frame3
animation.frame = 1
end
end
function love.draw()
love.graphics.draw(animation.image,0,0)
end
Error
Syntax error: main.lua:25: 'end' ex[ected (to close 'if' at line 11) near '<eof>'
traceback
[c]: ?
[C]: in function 'require'
[C]: in function 'xpcall'