Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help,
read this .
Dr.FR0ST
Prole
Posts: 2 Joined: Thu Apr 17, 2014 2:32 pm
Post
by Dr.FR0ST » Thu Apr 17, 2014 2:40 pm
Hi! I want to kill an enemy with bullet but every time i shoot i get an error. Thats my code:
Code: Select all
function Enemy:update(dt)
local i, o, w, s
for i, o in ipairs(Enemy) do
for w, s in ipairs(bullets) do
if (s.x > w.x and s.x < w.x + w.width) and (s.y > w.y and s.y < w.y + w.height) then
table.remove(bullets, w)
table.remove(Enemy, i)
end
end
end
end
Error:
veethree
Inner party member
Posts: 877 Joined: Sat Dec 10, 2011 7:18 pm
Post
by veethree » Thu Apr 17, 2014 3:15 pm
You don't need this line:
I think your problem is in this line:
Code: Select all
if (s.x > w.x and s.x < w.x + w.width) and (s.y > w.y and s.y < w.y + w.height) then
w in this case is a number value not a table, I think you meant to put the o from the other loop there.
Code: Select all
if (s.x > o.x and s.x < o.x + o.width) and (s.y > o.y and s.y < o.y + woheight) then
Dr.FR0ST
Prole
Posts: 2 Joined: Thu Apr 17, 2014 2:32 pm
Post
by Dr.FR0ST » Thu Apr 17, 2014 5:05 pm
Damn im so blind
Thank you! My problem is solved
Users browsing this forum: Bing [Bot] , Google [Bot] and 5 guests