1 Reply Latest reply on May 25, 2010 7:06 PM by JaxNa

    FootBall

    JaxNa Level 1

      Hi,

      I can get a tutorial/code/help for a football (soccer)game? A free kick game or penalty game would be great.

       

      Thanks,

      JaxNa

        • 1. Re: FootBall
          JaxNa Level 1

          Hi,

           

          Please can anyone help me for how to move ball depending upon speed from front view?

          I tried following this.

           

           

          var balls:Array = [];
          var ballSpeed:Number = 15;
          player_mc.swapDepths(10000);
          _global.golerAni = false;
          var speed:Number = 0;
          ///******************
          var intervalIDLine:Number;
          right_btn.onPress = function() {

           

              if (arrow_mc._rotation<0) {

           

                  arrow_mc._rotation = arrow_mc._rotation+5;

           

                  trace("speed="+speed);
              }
              intervalIDLine = setInterval(setAngleRight, 200);
          };
          right_btn.onRelease = function() {
              clearInterval(intervalIDLine);

           

          };
          function setAngleRight() {
              if (arrow_mc._rotation<0) {
                  arrow_mc._rotation = arrow_mc._rotation+5;
              }
          }

           

          left_btn.onPress = function() {
              if (arrow_mc._rotation>=-172.094131469727) {
                  arrow_mc._rotation = arrow_mc._rotation-5;
              }
              intervalLeftID = setInterval(setAngleLeft, 200);
          };
          left_btn.onRelease = function() {
              clearInterval(intervalLeftID);
          };
          function setAngleLeft() {
              if (arrow_mc._rotation>=-172.094131469727) {
                  arrow_mc._rotation = arrow_mc._rotation-5;
              }
          }

           

          function onEnterFrame() {
              /*if((goler_mc.f2||goler_mc.f3).hitTest(ball)){
              trace("hit")
              ball._x -= Math.cos(ball._rotation*Math.PI/180)*ballSpeed;
              ball._y -= Math.sin(ball._rotation*Math.PI/180)*ballSpeed;
              }*/
              for (i in balls) {
                  ball = balls[i];

           

                  ball._x += Math.cos(ball._rotation*Math.PI/180)*speed;
                  ball._y += Math.sin(ball._rotation*Math.PI/180)*speed;
                  ball._xscale -= 3.1;
                  ball._yscale -= 3.1;

           

                  if (ball._y<200 && _global.golerAni == false) {
                      goler_mc.gotoAndPlay("f2");
                      _global.golerAni = true;
                  }
                  if (ball._x<0 || ball._x>Stage.width || ball._y<=0 || ball._y>Stage.height) {
                      ball.removeMovieClip();
                      balls.splice(i,1);
                      press_btn.enabled = true;
                      display_ball._visible = true;
                  }
              }
          }
          var ballId:Number;
          function ballthrough() {
              if (speed<20) {
                  speed = speed+1;
                  //trace("speed="+speed);
              }
          }
          press_btn.onPress = function() {
              speed_mc.gotoAndPlay(2);
              if (speed<=20) {
                  ballId = setInterval(ballthrough, 200);
              }
              if (speed>1) {
                  speed = 1;
              }
          };
          press_btn.onRelease = function() {
              if (speed<=20) {
                  speed_mc.stop();
              }
              clearInterval(ballId);
              var ball:MovieClip = _root.attachMovie("ball", "ball_", _root.getNextHighestDepth());
              ball.swapDepths(10);
              ball._x = arrow_mc._x;
              ball._y = arrow_mc._y;
              ball._rotation = arrow_mc._rotation;
              balls.push(ball);
              display_ball._visible = false;
              press_btn.enabled = false;

           

          };

           

          Thanks

          JaxNa