|
-
[RESOLVED] getObjectsUnderPoint headache
Hey all,
I've been on this problem for about a week now and it's making me angry. I'm making this game where lots of bullets and lots of enemies are involved. I'm testing [bullet]-[enemy] and [bullet]-[environment object] collision using getObjectsUnderPoint(). All environment objects and enemies get spawned on the same parent movieclip object called Theatre. Enemies are irregularly-shaped and rotate depending on movement direction.
Okay, first, I created the bullet logic. Flies everywhere just fine, and I programmed it to destroy itself when it hits anything. I create environment objects. Bullets that collide on the environment objects disappear as instructed (here I tested that Theatre.getObjectsUnderPoint() returns the environment movieclip object ONLY... great!)
Here's where it becomes messed up. I add an enemy that runs around. Bullets that hit him only disappear sometimes... and during troubleshooting, I noticed that Theatre.getObjectsUnderPoint() returned the Shape object within the enemy movieclip ONLY, not the enemy movieclip itself as I expected. What's with the inconsistency? Also, why does Theatre.getObjectsUnderPoint() return nothing (MC object or otherwise) when the bullet so obviously overlaps the enemy movieclip? Something's got to return because something's obviously at that Point at that particular time right?
Common mistakes people tend to overlook that I took care not to:
- I made sure that I passed the xy coordinate relative to the stage object to getObjectsUnderPoint()
Thanks for any help guys, I'd almost give my soul to have this thing solved. (can you tell I'm desperate? :P)
Jay.
Last edited by thurinus; 08-07-2007 at 08:02 AM.
-
Okay, maybe there were too many questions in my original post. Let me try to ask each problem on its own for now. Here's a reworded question:
Let's say I have a class called Game, which is attached as the movie document class. Game has children called Enemy and EnvironWidget. Both Enemy and EnvironWidgets are movieclips that have squiggly vector graphics in them.
In Game, I have:
Code:
addEventListener(MouseEvent.MOUSE_UP,showMeCollisions);
private function showMeCollisions(e:MouseEvent):void{
trace(stage.getObjectsUnderPoint(new Point(mouseX,mouseY)));
}
When I click EnvironWidget and trace the resulting array, I get [object EnvironWidget]. Great! just as I expected. but if I do the same on Enemy, I get [object Shape]. Say what??
According to the documentation, the method getObjectsUnderPoint() should return ALL children that's under the point specified. So if it were to faithfully follow this spec, I'd expect clicking on EnvironWidget to return [object EnvironWidget],[object Shape], and clicking on Enemy to return [object Enemy],[object Shape]. But obviously it isn't. What's happening?
Thanks for any help!
Jay.
Last edited by thurinus; 08-07-2007 at 08:34 PM.
-
I'm taking this to the Kirupa forums for now Thanks everyone who has looked.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|