Drop, Bounce, Collide, Bounce?

Hey Cody,
That works like a champ! soooo cool!

I muscled out some code for a double click function . . . so when you double click the ball, a new browser window opens.

I added this code to the bottom of the actionscript for the ball:


on (release) {
if(getTimer()-lastClick < 500){
getURL('http://www.google.com');
}
lastClick=getTimer();
}

If I have any other questions I’ll be sure to ask!!

Thanks,

Hondo311

Hey again Cody . . .

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?

Thanks!

Hondo311

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.

~Cody

Thanks for trying Cody . . .

. . . anyone else have any suggestions?

Hondo311

No problem. Good luck in the future. PM when you finish whatever your using this for. I’d like to see it. :slight_smile:

~Cody

Hi Guys,

any chance of posting an fla???

Im working on a similar project and am stumped on the collide part.

Hope you can help.

thanks

[quote=Hurley;2349852]Hi Guys,

any chance of posting an fla???

Im working on a similar project and am stumped on the collide part.

Hope you can help.

thanks[/quote]

Look at my above posts. I have the commented source file from before up there in zip format already.

~Cody

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.

Then again I could be wrong =P

[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.

~Cody