Page 1 of 1

HC:remove doesn't work [solved]

Posted: Sun Apr 05, 2020 5:33 pm
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.

Re: HC:remove doesn't work

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

Have you tried HC.remove instead of HC:remove?

Re: HC:remove doesn't work

Posted: Sun Apr 05, 2020 8:46 pm
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!