Code: Select all
Error
main.lua:34: attempt to call method 'draw' (a nil value)
Traceback
main.lua:34: in function 'draw'
[C]: in function 'xpcall'
Code: Select all
local anim8 = require "anim8/anim8"
local player
function love.load()
local walk = love.graphics.newImage("turtle_walking.png")
local g = anim8.newGrid(32, 32, walk:getWidth(), walk:getHeight())
player = {
-- player attributes
animations = {
right = anim8.newAnimation(g('1-2',1), 1)
}
}
player.animation = player.animations.right
end
function love.update(dt)
player.animation:update(dt)
if next(love.touch.getTouches()) ~= nil then
player.x = player.x + (player.speed * dt)
player.animation = player.animations.right
end
if love.keyboard.isDown("d") then
player.x = player.x + (player.speed * dt)
player.animation = player.animations.right
end
end
function love.draw()
player.animations:draw(player.walk, player.x, player.y)
end