Animated pixelmask has a huge hitbox?


(John Andersson) #1

Okay, so if I have a non-animated entity with a pixelmask, then the collision detection is dandy, but if I have an animated entity with a pixelmask, then the hitbox is bigger than the entity (if I pause the game with the console, then I can see the other spritemap index animations to the right of the entity). How and why is it like this? How do I fix it?


(Martí Angelats i Ribera) #2

So you’re using a Spritemap? How do you set the mask?


(John Andersson) #4

this i what I use

mask = new Pixelmask(graphic, -13, -12);


(Martí Angelats i Ribera) #5

OK that’s not the way to do it. You are making a Pixelmask of ALL the tiles together.

Do you want a square hitbox? Just use this (obviously you’ll probably have to change the values)

originX = 0;
originY = 0;
width = 16;
height = 16;

Do you want a static Pixelmask? You’ll have to create another image, embed it and create the pixelmask with it

[embed(etc.)]
public const MASK:Class;

//and then 
mask = new Pixelmask(MASK);

Do you want an animated Pixelmask? Have a look at this thread.

PD: The last soluction requieres some conditions and you may have to create a second spritemap for the collision.