Help with Error.
Posted: Sat Jul 07, 2012 11:32 pm
I was trying to code my testgame when I got an error when trying to make my "Hero" a picture I made.
Here is my code
I get this error:
main.lua23:Incorrect parameter type: expected userdata
Traceback
[C]: in function 'draw'
main.lua23: in function 'draw'
[C]: in function 'xpcall'
Code to fix the problem would be greatly appreciated.
Thanks in Advance!
Here is my code
Code: Select all
function love.load()
hero = {} -- new table for the hero
hero.x = 300
hero.y = 450
hero.speed = 200
end
function love.update(dt)
if love.keyboard.isDown("left") then
hero.x = hero.x - hero.speed*dt
elseif love.keyboard.isDown("right") then
hero.x = hero.x + hero.speed*dt
end
end
function love.draw()
-- draws the ground
love.graphics.setColor(0,255,0,255)
love.graphics.rectangle("fill",0,465,800,150)
love.graphics.rectangle("fill", 0,465,800,150)
--draws the hero
love.graphics.draw("Hero.png", hero.x,hero.y, 30, 15)
end
main.lua23:Incorrect parameter type: expected userdata
Traceback
[C]: in function 'draw'
main.lua23: in function 'draw'
[C]: in function 'xpcall'
Code to fix the problem would be greatly appreciated.
Thanks in Advance!