Hi,
I recenley started coding and I recieve an error when I run my code. ( on my PC). It states "Bad argument #2 to 'blit' <image expected, got table>
Here is my code. If you could pleases help me fix it I would be very grateful....
THNX :)
arrow = Image.load("arrow.png")
grass = Image.load("grass.png")
screenwidth = 480 - arrow:width()
screenheight = 272 - arrow:width()
arrow = {}
arrow[1] = { x = 200, y = 50}
--***** Main Loop *****
while true do
pad = Controls.read()
screen:clear()
for a = 0, 14 do
for b = 0,8 do
screen:blit(32 * a, 32 * b, grass)
end
end
screen:blit(300,220,arrow)
if pad:left() and arrow[1].x > 0 then
arrow[1].x = arrow[1].x - 2
end
if pad:right() and arrow[1].x < screenwidth then
arrow[1].x = arrow[1].x + 2
end
if pad:up() and arrow[1].y > 0 then
arrow[1].y = arrow[1].y - 2
end
if pad:down() and arrow[1].y < screenheight then
arrow[1].y = arrow[1].y + 2
end
screen.waitVblankStart()
screen.flip()
end
Help with screen:blit...
Moderators: Shine, Insert_witty_name
Code: Select all
arrow = Image.load("arrow.png")
grass = Image.load("grass.png")
screenwidth = 480 - arrow:width()
screenheight = 272 - arrow:width()
arrow = {}
arrow[1] = { x = 200, y = 50}
...
Geo Massar
Retired Engineer
Retired Engineer
- daurnimator
- Posts: 38
- Joined: Sun Dec 11, 2005 8:36 pm
- Location: melbourne, australia
Re: Help with screen:blit...
arrow = Image.load("arrow.png")
grass = Image.load("grass.png")
screenwidth = 480 - arrow:width()
screenheight = 272 - arrow:width()
arrow = {}
arrow[1] = { x = 200, y = 50}
--***** Main Loop *****
while true do
pad = Controls.read()
screen:clear()
for a = 0, 14 do
for b = 0,8 do
screen:blit(32 * a, 32 * b, grass)
end
end
screen:blit(300,220,arrow)
if pad:left() and arrow[1].x > 0 then
arrow[1].x = arrow[1].x - 2
end
if pad:right() and arrow[1].x < screenwidth then
arrow[1].x = arrow[1].x + 2
end
if pad:up() and arrow[1].y > 0 then
arrow[1].y = arrow[1].y - 2
end
if pad:down() and arrow[1].y < screenheight then
arrow[1].y = arrow[1].y + 2
end
screen.waitVblankStart()
screen.flip()
end
Pretty much just replace the blue words with "arrowImg".
BTW, you screwed your quote tag up. It says daurnimator wrote that, when it was me..