I understand what you said about objects bouncing based n a BOX that’s around them . . . is there a way to tweak the code so that irregular shapes (that aren’t perfectly square, like rectangles or triangles) will work too?
Well… I know that it is possible, but that is beyond my current abilities. I tried several methods of doing it, and none of them worked very well. You might be able to rig something up for a circle using it’s radius, but I’m not sure how to go about it for the other ones.
I understand what you said about objects bouncing based n a BOX that’s around them . . . is there a way to tweak the code so that irregular shapes (that aren’t perfectly square, like rectangles or triangles) will work too?
Unless I’m mistaken, using this bounding box method is just a hitTest that you’ve coded yourself, so I don’t know why ShadowViper advocated not using hitTest on each side of the object. HitTest has the advantage of being able to evaluate a shape or a bounding box by enabling or disabling the shapeFlag (for more info see: http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary534.html)
So, I’m fairly certain that using hitTest with a shapeflag on, say, each side of a triangle, would have the effect you desire.
[quote=thesean;2349885]Unless I’m mistaken, using this bounding box method is just a hitTest that you’ve coded yourself, so I don’t know why ShadowViper advocated not using hitTest on each side of the object. HitTest has the advantage of being able to evaluate a shape or a bounding box by enabling or disabling the shapeFlag (for more info see: http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary534.html)
So, I’m fairly certain that using hitTest with a shapeflag on, say, each side of a triangle, would have the effect you desire.
Then again I could be wrong =P[/quote]
Well, I’m not sure if you are correct or not. For me, using a bounding box has a few advantages.
-It gets you used to detecting collisions in the event that you were to ever use a language without a hittest-type function.
-it makes it easier for me to determine what side something is being hit on so that I can then react to that and make the object do something (i.e. bounce, move, etc) based on which side it was hit on. I have tried using hittest for this type of thing and it has just never worked very well for me.
-it seems like it might be more efficient (but I can’t say that this claim has any supporting evidence or truth to it). Just a guess I have really. I’m not sure how a hittest is calculated so this may be wrong entirely.