开发者

Sphere to Rectangle collision detection in actionscript 3.0?

开发者 https://www.devze.com 2022-12-27 15:20 出处:网络
for the past two weeks I\'ve been working on coming up with a collision detection system for my game in flash CS4.No matter what I try for some reason I just can\'t seem to do it, and I don\'t know ho

for the past two weeks I've been working on coming up with a collision detection system for my game in flash CS4. No matter what I try for some reason I just can't seem to do it, and I don't know how to fix it. This has never been an issue for me, I would even settle for basic rectangle to rectangle collision if I could, but no matter what I do I end up screwing it at all up. Somehow the collision detection either doesn't work at all, works for one side and jumps the guy through the wall on any other side or I think at one point it worked for two sides as long as I didn't hold down more than one movement key.

I've constantly scrapped what I've done over and over, right now I have no source code to present. I'm totall开发者_开发技巧y lost and confused, and my deadline for getting this done is today in a few hours. I really wanted to figure this out on my own but honestly I just don't see what I can do, I've got sphere to sphere collision detection working perfectly for my player and other spheres, but the walls are squares lined up to form long rectangles, and I just can't seem to get it to work. I'm dynamically loading the square-wall blocks as tiles to form a dynamically loaded map, and then I'm iterating through each individual block to determine if collision has occurred with the player. I think somehow I'm not managing the results right, or maybe I somehow need to be able to determine which direction the player hit the wall from, but I just don't know how to do it.

I'm really sorry for not being able to give source code, I just literally don't have anything. I've been staring at the screen for the past 3 hours trying to work something out but nothing is coming to me, so please if anyone can help me with an example from a flash-type game or something similar I would be very grateful! (I've done this countless times in C++, C#, and java. I don't get what is going on in flash :-(((( )


This may help you... http://www.tink.ws/blog/as-30-hittest/


Don't despair, we've all been there at one point :)

Use a 2d physics engine if it's something more complicated.It can get you up ad running pretty fast:

http://box2dflash.sourceforge.net/

Some tutorials on this can be found here: http://www.emanueleferonato.com/category/box2d/

You can check more tools for flash developers here:

http://flashontherocks.com/flash-developer-toolbox/

0

精彩评论

暂无评论...
验证码 换一张
取 消