Page 1 of 1

huller: a tool to generate a collision shape from an image

Posted: Tue Sep 06, 2016 1:10 am
by clofresh
Hello,

I wrote a small command line tool called huller to generate a collision shape from an image: https://github.com/clofresh/huller

The idea is to generate the collision shape outside of your game like this:

Code: Select all

./huller path/to/sprite.png > sprite.lua
And then in your game you can do (assuming you're using HC):

Code: Select all

HC = require('HC')

function love.load()
  spriteShapeData = require('sprite')
  sprite = {
    image = love.graphics.newImage('path/to/sprite.png'),
    shape = HC.polygon(unpack(spriteShapeData)),
  }
end

function love.draw()
  sprite.shape:draw()
  love.graphics.draw(sprite.image)
end