I am trying to use HC for my small hobby project game and I have immediately run in to an issue.
My Entity objects store their own shapes created by using the standard methods (e.g. HC.rectangle(x, y, w, h)). Since I need multiple collision layers I then register the shape in the HC instances kept in the World object like so:
-- Add an entity to the world
function World:addEntity(entity)
-- Give the entity an ID
entity.ID = self:getNewID()
if entity.collidable then
self.collider:register(entity.shape)
end
-- Use that ID to add the entity
self.entities[entity:getID()] = entity
end
When doing this I immediately get the error
Error: modules/HC/spatialhash.lua:49: attempt to perform arithmetic on field 'cell_size' (a table value)
stack traceback:
modules/HC/spatialhash.lua:49: in function 'cellCoords'
modules/HC/spatialhash.lua:101: in function 'register'
modules/HC/init.lua:60: in function 'register'
world.lua:37: in function 'addEntity'
abstracts/entity.lua:47: in function 'addToWorld'
actors/player.lua:64: in function 'initialize'
modules/middleclass.lua:122: in function 'new'
main.lua:55: in function 'load'
[string "boot.lua"]:440: in function <[string "boot.lua"]:436>
[C]: in function 'xpcall'
I have been drilling down a bit and it seems that somehow during the register operation the self.cell_size field gets overwritten by the init table. The following is the print out of what self.cell_size contains when executing the register.
I am trying to use HC for my small hobby project game and I have immediately run in to an issue. My Entity objects store their own shapes created by using the standard methods (e.g.
HC.rectangle(x, y, w, h)
). Since I need multiple collision layers I then register the shape in the HC instances kept in the World object like so:When doing this I immediately get the error
I have been drilling down a bit and it seems that somehow during the register operation the self.cell_size field gets overwritten by the init table. The following is the print out of what
self.cell_size
contains when executing the register.Am I misusing the lib or is this a pretty serious bug?