8 Replies Latest reply on Nov 18, 2015 6:53 AM by Colin Holgate

    HTML5 Tween JS couple of animations, executes only the first

    jakubs67316906

      Hello everyone,

       

      I'm new to HTML5 in Adobe Flash and I have one problem, i have this code:

       

      for(x = 0; x < solution.length; x++) {

         

      if(solution[x] == playerSolution[x]){
      switch(solution[x]){
      case "f":
      moveForward(); 1000);
      break;
      case "l":
      turnLeft();
      break;
      case "r":
      turnRight();
      break;
      }
      }
      else{

       

      the functions moveForawrd(), turnLeft(), turnRight() trigger animations, but even if the functions are called in the for cycle more than once, only the first animation executes.

      Code for the moveForward() function

       

      function moveForward() {

       

       

        if (direction == "north") {

             var position = { x : p.x, y: p.y-80 };

        }

       

        if (direction == "south") {

             var position = { x : p.x, y: p.y+80 };

        }

       

             if (direction == "east") {

             var position = { x : p.x+80, y: p.y };

        }

       

       

             if (direction == "west") {

             var position = { x : p.x-80, y: p.y };

        }

       

       

          var tween = createjs.Tween.get(p)

        .to(position, 1000);

      }

       

      Where is the problem please? Thank you very much for your responses