0 Replies Latest reply on Jan 20, 2013 4:28 PM by Sphynxinator

    Some Sonic Engine Problem...

    Sphynxinator

      Hello all. I was making a Sonic Engine in Flash, but I had some problems with it. I tried to solve the problem for a long time but I haven't taken any results. Firstly, I want to give the fla file.

       

       

      http://www.mediafire.com/?8nncuslgjv2oxb2 (Sorry for the size)

       

       

      Here's the code that starts at line 56:

       

       

          if(spx == 0 || spx < 0)

          {

                    isDirectionRight = false;

                    mcSonic.scaleX = -1;

          }

          if(spx < dec && spx > 0)

          {

                    isDirectionRight = false;

                    mcSonic.scaleX = -1;

                    spx = -dec;

          }

          if(spx >= dec)

          {

                    spx += -dec;

          }

          if(Math.abs(spx) >= 4.5){

          if(!isBrake)

          {

                    sonicBreak = true;

                    isBrake = true;

          }

          }

       

       

      These if stacks are triggered when user presses left key. But third "if" code is not triggered even the spx value is equal or greater than dec value. I don't understand why it is not triggered.

       

       

      Second problem is, when user triggers "if(!isBrake)", sonicBreak becomes true. Here's the part of the code that I think where the problem occurs in(starts at line 380):

       

       

          if(sonicBreak)

                {

                          sonicJumpingCounter = 0;

                          jumpCnt = 0;

                          sonicWalkingCounter = 0;

                          walkCnt = 0;

                          if(mcSonic.currentFrame < 9 || mcSonic.currentFrame > 20){

                                    mcSonic.gotoAndPlay("sonicBreak");

                          } else if (mcSonic.currentFrame >= 9)

                          {

                                    mcSonic.nextFrame();

                          }

                          trace(mcSonic.currentFrame);

                }

       

                if(mcSonic.currentFrame == 20)

                {

                          sonicBreak = false;

                          sonicStand = true;

                }

       

       

      He should play the brake animation and when he is in the twentieth frame, he should go to standing animation, but instead of this, it stucks on the ninth frame. I don't know why this one happens either.

       

       

      Thanks for the help.