Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

i have a code segment in which i use hitTest() a couple of times. and at a particular section the hitTest stops working. it doesnt test the collision of body a and body b

i tried using _level0.exit.hitTest(ourcar._x,ourcar._y,true)

along with exit.hitTest(ourcar._x,ourcar._y,true)

both doesnt work?why?

share|improve this question
2  
This should be phrased much better. At the very least capitalize your sentences and use some punctuation. –  Sean James Aug 14 '10 at 11:02
    
To answer this we would need more details about your code –  Ben Zeigler Aug 15 '10 at 20:21
add comment

2 Answers

up vote 1 down vote accepted

you can use these function

hitTestObject(obj:DisplayObject):Boolean
Evaluates the display object to see if it overlaps or intersects with the obj display object.


hitTestPoint(x:Number, y:Number, shapeFlag:Boolean = false):Boolean
Evaluates the display object to see if it overlaps or intersects with the point specified by the x and y parameters.

http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html

share|improve this answer
    
thankyou, but I found out the solution sometime back. –  Vishnu Sep 21 '10 at 4:05
    
You should at least update the question to tell what you figured out. –  AttackingHobo Oct 28 '10 at 5:57
add comment

This is a very specific problem and is very hard to answer without some knowledge about your code. I'm not sure if gamedev is the right place for this kind of question?

My guess is that your entities aren't located in the same coordinate space. Is the ourcar entity placed in the same level as the exit entity? If exit is on _level0, then ourcar needs to be on _level0 as well. Otherwise you'll have to convert the coordinates of ourcar to the coordinate-space of _level0 and then perform the hit-test using these coordinates.

Edit: Sorry, it has been a long time since I last used hitTest. According to this page, the x and y coordinates must always be global coordinates. So you have to make sure the x and y coordinates are relative to the global coordinate space. You can use localToGlobal to calculate these.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.