1 decade ago
by grelca
Is there any way to check for collisions against only part of an entity? For instance in a flyswatter type game, I'd want to move around the swatter with the mouse, but only the top half of the swatter overlapping a bug on click should count as hitting the bug.
No. I requested a hitbox in Impact last month and posted this
sample code. This'll start you in the right direction. You'll still need to rewrite ig.Entity.solveCollision, ig.Entity.separateOnXAxis & ig.Entity.separateOnYAxis.
1 decade ago
by Arantor
Or you can fudge it by using a smaller size for the entity than it actually is and using offset to reposition the image.
The actual drawing size of the image is basically irrelevant to the size defined for the entity itself.
Been making good use of that today, actually, where the ship that flies around shouldn't take into account the bottom 1/3 of the image because that's where the 'thrusters' fire and in a lunar lander type game, you don't want to hit the ground funny ;)
It's not elegant and a proper hitbox solution would be preferable but it's already half way there.
1 decade ago
by grelca
Thank you both! I'd completely missed the offset property on entities, I'm using that :)
Page 1 of 1
« first
« previous
next ›
last »