HC:remove doesn't work [solved]

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.
Post Reply
o08oo
Prole
Posts: 2
Joined: Sun Apr 05, 2020 4:57 pm

HC:remove doesn't work [solved]

Post by o08oo »

I'm trying to clear the scene in order to load another one, but no matter what I try I can't clear the collision objects.
I tried

Code: Select all

for i = 1,#self.walls do
	self.HC:remove(self.walls[i])
end
and the error is
HC/init.lua:75: attempt to call method 'bbox' (a nil value)
I also tried

Code: Select all

for i = 1,#self.walls do
	local hash = scene.HC:hash()
	hash:remove(self.walls[i], self.walls[i]:bbox())
end
which gives the error
HC/init.lua:49: attempt to index local 'self' (a nil value)
More info in code tags because I don't know how to do inline code:

Code: Select all

"self.walls[i]" definitely exists because "self.player:moveTo(self.walls[i]._polygon.centroid.x,self.walls[i]._polygon.centroid.y)" works (inside the loop) so that's probably not the problem, and "self.walls[i]:bbox()" works too.
Move to the yellow square and press e.
Attachments
gametest - Copy (6).love
(78.15 KiB) Downloaded 131 times
Last edited by o08oo on Sun Apr 05, 2020 8:49 pm, edited 1 time in total.
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: HC:remove doesn't work

Post by pgimeno »

Welcome to the forums!

Have you tried HC.remove instead of HC:remove?
o08oo
Prole
Posts: 2
Joined: Sun Apr 05, 2020 4:57 pm

Re: HC:remove doesn't work

Post by o08oo »

pgimeno wrote: Sun Apr 05, 2020 7:38 pm Welcome to the forums!

Have you tried HC.remove instead of HC:remove?
Thank you, it worked!
Post Reply

Who is online

Users browsing this forum: No registered users and 220 guests