-
Collision detection?
Hello, im makign an online game.
here is the link so you can get an idea: http://jpoel.x10hosting.com/OnlineGame/
basically, players are added to the room in the order they come in
what i'm wanting, is for player movie clip index's to be reordered as they hit eachother
for example, in this instance..
player james is closer to the bottom of the screen than player 13the13, yet 13the13 appears to be above player james
i want the two movie clips to reorder themselves when this happens, so really, i want something like this
Code:
if(PlayerA hits PlayerB){
if(PlayerA.y > PlayerB.y){
Put PlayerA infront
}else{
Put PlayerB infront
}
}
the movie clip names of the characters are generated dynamically, and are a random number, so im guessing i cant use hitTestObject.
Any help would be appreciated!!
Last edited by JamesPoel; 01-03-2010 at 09:32 PM.
-
WOWW i managed to fix it all by myself! heres the code if anyone is interested!
Code:
this.addEventListener(Event.ENTER_FRAME,sortCharacters);
function sortCharacters(event:Event){
var viewItems = new Array();
for(var i=0; i<characters.numChildren; i++) {
viewItems.push(characters.getChildAt(i));
}
viewItems.sortOn("y", Array.NUMERIC);
for(var e=0; e<viewItems.length; e++)
{
//this.addChild(viewItems[e]);
this.characters.setChildIndex(viewItems[e],e);
}
}
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
|