Hello.
I use HardonCollider for collision detection and it works pretty good. But I need to draw a player sprite and move it with its bounding box together. How can I do this?
Thank you .
Physics and images (HardonCollider)
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Physics and images (HardonCollider)
Probably the easiest way would be to use shape:center() to get the shape center and use the numbers returned to draw the sprite at the right place.
Kurosuke needs beta testers
Re: Physics and images (HardonCollider)
Thanks, it works, but the sprite draws at left-bottom corner of the bounding box. How can I fix it? Also, if I try to add other arguments to love.graphics.draw, the sprite doesn't move down with the box, only on x axis.
hero is:
Code: Select all
function love.draw()
love.graphics.draw(heroImage, hero:center(x))
end
Code: Select all
hero = collider:addRectangle(x,y,16,16)
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Physics and images (HardonCollider)
Code: Select all
function love.draw()
local hx, hy = hero:center()
love.graphics.draw(heroImage, hx - 8, hy - 8)
end
Kurosuke needs beta testers
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Physics and images (HardonCollider)
You're probably better off using the origin arguments (ox and oy), because they correctly handle rotation as well.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests