In my top-down as3 game, collision between the player and a warp point works once, changing the background and moving the player, and then back again on colliding with the exit warp. When re-colliding with the first warp point again, the collision isn't detected and the warp + background change just doesn't happen. Heres the code.
Sorry if its very specific, maybe someone out there knows.
if you think its stupid to even write flash just dont bother replying pls >:(
stage.addEventListener(Event.ENTER_FRAME, testCollision); function testCollision(e:Event):void{ if ( warp1.hitTestPoint(player.x, player.y, true)){ collideWarp1 = true; } else { collideWarp1 = false; } if ( warp2.hitTestPoint(player.x, player.y + 10.5, true)){ collideWarp2 = true; } else { collideWarp2 = false; } }
Then these two triggers are posted in the walk down and walk up prompts.
// walking down / exiting house if (collideWarp2){ doWarp2(); } // walking up / warping into house if (collideWarp1){ doWarp1(); } // referencing these functions function doWarp1():void{ // set collision box and background to inside the house collide1.gotoAndPlay(2); BG1.gotoAndPlay(2); gotoAndStop(2); // warp player to inside door location player.x = 227.00; player.y = 195; // remove door door1.visible = false; } function doWarp2():void{ // set collision map and background to overworld collide1.gotoAndPlay(1); BG1. gotoAndPlay(1); // set player position at the door player.x = 383.9 ; player.y = 241.95; gotoAndStop(1); //bring back in door and reset its anim to be closed. door1.visible = true; door1Open = false; door1.gotoAndStop(1); }
It has no problem using the same boolean system to constantly detect all of the other collisions of the game [player + collision box] So I dont understand why the warp stops working after one test, even though its triggered within the test collision function which supposedly triggers every ENTER_FRAME [ constantly ]