18 Replies Latest reply on Apr 19, 2017 6:12 AM by kglad

    How can I fix my walls in my maze game in Adobe Animate? Please help meee ;A;

    purowag

      This is the code that I've used. My issue is that, the character will stop in the near center of the screen without moving to the right, before touching the wall. the left and upper walls are fine, however. I need the character to have free movement other then wall colision. This is my final project for class and I'm ahead of scheduale because i want to laze around later.

       

      My character is "mc_glo"

      The wall is called "mc_wall1"

      the collectables are "mc_scout1" and "mc_zombie1"

       

      stage.addEventListener(KeyboardEvent.KEY_DOWN, checkkeysdown);

      stage.addEventListener(KeyboardEvent.KEY_UP, checkkeysup);

       

       

      var moveup:Boolean=false;

      var movedown:Boolean=false;

      var moveleft:Boolean=false;

      var moveright:Boolean=false;

       

       

      var speed:Number=10;

       

       

      function checkkeysdown (mykey:KeyboardEvent) {

        if (mykey.keyCode==Keyboard.UP) {

        moveup=true;

        }

       

        if (mykey.keyCode==Keyboard.DOWN) {

        movedown=true;

        }

       

        if (mykey.keyCode==Keyboard.LEFT) {

        moveleft=true;

        }

       

        if (mykey.keyCode==Keyboard.RIGHT) {

        moveright=true;

        }

      }

       

      function checkkeysup(mykey:KeyboardEvent) {

        if (mykey.keyCode==Keyboard.UP) {

        moveup=false;

        }

       

        if (mykey.keyCode==Keyboard.DOWN) {

        movedown=false;

        }

       

        if (mykey.keyCode==Keyboard.LEFT) {

        moveleft=false;

        }

       

        if (mykey.keyCode==Keyboard.RIGHT) {

        moveright=false;

        }

      }

       

      stage.addEventListener(Event.ENTER_FRAME, gameloop);

       

       

      function gameloop(evt:Event) {

        if (moveup==true) {

        if (!mc_wall1.hitTestPoint(mc_glo.x,mc_glo.y-10,true)) {

        mc_glo.y-=speed;

        }

        }

        if (movedown==true) {

        if (!mc_wall1.hitTestPoint(mc_glo.x,mc_glo.y+10,true)) {

        mc_glo.y+=speed;

        }

        }

        if (moveleft==true) {

        if (!mc_wall1.hitTestPoint(mc_glo.x,mc_glo.x-10,true)) {

        mc_glo.x-=speed;

        }

        }

        if (moveright==true) {

        if (!mc_wall1.hitTestPoint(mc_glo.x,mc_glo.x+10,true)) {

        mc_glo.x+=speed;

        }

        }

        pickUp();

      }

       

       

      function pickUp(){

        if (mc_glo.hitTestObject(mc_scout1)){

        mc_scout1.x=1000;

        }

        if (mc_glo.hitTestObject(mc_zombie1)){

        mc_zombie1.x=1000;

        }

      }

       

      [Moved from non-technical Lounge Forum to specific Program forum... Mod]

      [Here is the list of all Adobe forums... https://forums.adobe.com/welcome]