I had no problem doing this in AS2 when I tried creating grounds in a sidescroller shooter game, but with AS3 the only way i can figure it out seems inefficient (though it does work). I’m trying to simplify the following code to make less copy and paste work for myself because I’ll end up having many more platforms for the player to jump from.
…
if (!jumping && (!player_mc.hitTestObject(background_mc.ground_mc1) || !player_mc.hitTestObject(background_mc.plat_mc1)|| !player_mc.hitTestObject(background_mc.plat_mc2) || !player_mc.hitTestObject(background_mc.ground_mc2))) {
jumping= true;
jump = 0;
}
if (falling && (player_mc.hitTestObject(background_mc.ground_mc1) || player_mc.hitTestObject(background_mc.plat_mc1) || player_mc.hitTestObject(background_mc.plat_mc2) || player_mc.hitTestObject(background_mc.ground_mc2)) ) {
jump = 20;
jumping = false;
falling = false;
}
…
as you can see i’m just checking every MC within my background_mc for collision. Ideally I would like to have one check here for collision, but if i were to run the same check on just background_mc the player is counted as colliding even when in open space because of how flash draws its boxes around the movie clips. Does anyone have any suggestions for how i should approach this? It’s not to big of a deal right now but when i decide to place my walls into the game it will become a major pain.