The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > Graphic & Game Programming > Flash ActionScript


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Tags:

Closed Thread
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 06-10-2007, 04:22 PM
Multimediocrity
Posts: n/a
[SOLVED] Question about programming ActionScript in Flash - How do I do collision det

I want to detect collision between two objects based on the image. I can use hittest for this, but I want the collision to be true when object A hits object B's image instead of object B's bounding box.

Example: Say I have an arch. If object A goes inside the arch (not touching it), it will register as a hit, although I never acutally touched the image. How can I say that the hit is true only when object A touches the image?
Thanks to all of you who answered so far. I'll have to try these when I get home tonight. Thanks! Still looking for answers though.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
  #2 (permalink)  
Old 06-10-2007, 04:22 PM
boris
Posts: n/a
You need a method to get the pixel contents. There is a value for transparent pixels. You need to put logic in to compare the individual pixels, and flag if theres a collision between 2 non-transparent pixels. This is the only way. I'm sorry I do not have the actual function definitions available, but any good reference on flash graphics libraries should do the trick.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
  #3 (permalink)  
Old 06-10-2007, 04:22 PM
Joey
Posts: n/a
Quick note without testing....

Can you just do a hitTest with the image and what u want.

for example object A and object B are on the root timeline- ur image is inside object B. make ur image be inside a movie clip which in turn is inside object B. then do a hit test with onjectB.image instead of just object B. Hope that makes sense.

heres some dirty code for ya:

box_mc.onPress = function() {
startDrag(this);
};
this.onEnterFrame = function() {
if (box_mc.hitTest(circle_mc.circle2_mc)) {
trace("you hit the circle");
}
};

there are 2 objects on the stage. box_mc and circle_mc, then circle2_mc (which is inside circle2_mc- where ur image would be.)

send em a note if u have questions and please forgive any yahoo formatting to the code.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
  #4 (permalink)  
Old 06-10-2007, 04:22 PM
Max
Posts: n/a
visit www.actionscript.org tutorials section and search for hit test keyword Enjoy!

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Closed Thread


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 10:47 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50