Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Hey Roger thanks for your answer. Do you have any examples or anything I could take a look at. I am getting stuck at the point where I evaluate the intersecting points to check for a collision of non alpha values. I'll edit my post with some code h=that I have now. Thanks!
yeah thinking about it more and more I wouldn't mind per pixel detection but if I can get it to work without the use of it then I'll just implement that way. maybe I'll draw a circle instead of a box for right now and check to see if the enemy hits that. My hero is pretty much circular anyways. Thanks for your answer.
Also really I am just confused on how to check if it is a pixel by pixel collision rather than bounding boxes. Like if you get the non alpha pixels of the enemy and hero but how do you check if those overlap as well.
Thanks Jari, I wanted to implement some per pixel collision into my game for when the enemy hits the hero sprite because right now the bitmap has some transparent points in front of the hero. I was just hoping someone could explain the steps involved for achieving this. I am already checking if bounding boxes are intersecting and then was going to implement per pixel collision.
Hey Roger, thanks for your answer, Ialmost go this to work fo rme by using this code <pre>setenemyPositionY(getenemyPositionY() + Math.sin(getRotation() * (Math.PI / 180))); setenemyPositionX(getenemyPositionX() + Math.cos(getRotation() * (Math.PI / 180))); </pre> Is this what you were talking about? This seems to work however alwasy launches the enemy to my right. Ill keep working on it though. Thanks for your help.
Hey Thanks. That confirms what I was trying today. I started to offset the rotation by an increment based on what frame the animation is on as well as finding the center for that frame by the frames width and height divided by two. Still didn't get it quite right though. I did notice some fuzzy and jagged edges being created when rotating as well. I'll take your advice it is much appreciated and exactly what I was looking for.