![]() |
|
|
|
| ||||||
|
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: |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| [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. |
| |
| |||
| 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. |
| |||
| 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. |
![]() |
| Thread Tools | |
| Display Modes | |
| |