Hi all
,
Sincerest apologies if this question has been asked before, but I have run into a little issue in collision detection (I'm a rookie in coding :P). I'm developing a game where my sprite, the "Hero", does some dynamic animations such as stretching his limbs far across the screen.
My issue is that the Gideros Texture Packer packs images in simple shapes (squares, rectangles) and from my limited understanding collision is applied to the entire image. Does that mean when my Hero stretches his arm to the right, collision must applied to the whole sprite including the empty space above and below his outstretched arm? I'm worried about this because I have a small enemy that crawls on the floor, and I don’t want the Hero's outstretched arm to register a collision even though his arm completely misses the crawling enemy.
Thanks for reading and hope to hear from the community soon!
Comments
it all depends on what collision detection are you using.
If you are using something as simple as Sprite:hitTestPoint(x,y) then yes, whole area would count.
Additionally you can divide one image as many, as in, use arm as separate graphic, etc.
Then you can use Box2d where the collision would be defined by the fixtures you use for bodies and not by the image, giving you the full control.
If you do not need the physics, which box2d is made for, then you can achieve same thing with TNT Collision Engine: http://www.tntparticlesengine.com/?cat=15
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
Thank you so much for your help, I ended up using the TNT Collision Engine for my game and it fixed the problem. You guys are a great community