3 Replies Latest reply on Jul 1, 2012 2:54 PM by infeter

    Artifacts when moving object with arrow keys.

    LiquidSnake88

      Hi all

       

      hope this is the right place to post this question.

      I want to to write simple arkanoid game in Flash (AC3). I've managed to write code that  moves my paddle with arrow keys. The code looks like this:

       

      function OnNewFrame(event:Event):void
      { 
          if (input.IsLeftHeld)
          {
              if (paddle.x > 0)
              {
                  paddle.x -= 10;
              }
          }
          else
          if (input.IsRightHeld)
          {
              if (paddle.x < stage.stageWidth - paddle.width)
              {
                  paddle.x += 10;
              }
          }
      }
      

       

      It works but the result is ugly. The animation is not fluent, there are times when paddle stops for a moment . Also when speed of translation is high (here it is 10) you can see that paddle is flickering at the ends, it looks like single buffering problem. You can see both of those effects here:  http://www.flash-game-design.com/flash-tutorials/movOb.html , hovewer flickering is less visible due to small translation amount.

      How to fix this? How can i enable double buffering (or maybe it is enabled by default)?  Any help will be appreciated.

       

      P.S. sorry for bad english

        • 1. Re: Artifacts when moving object with arrow keys.
          infeter

          Hi! I think you went the wrong way... First - in order to achieve the best visual transitions - you must not use speed of translation at all. Second - you must pay attention to the Flash document's frame rate setting. Vivid games usually run at 60 frames per second. So I've made a sample for you. Try it there: http://cdn.dmldevelopment.com/plugins/tests/paddle/paddle.html . You can use direction keys plus a space key to see how smooth the transitioning is. And you can download the source code there: https://rapidshare.com/files/3779443821/paddle.zip . Please let me know if i helped you. Cheers!

          • 2. Re: Artifacts when moving object with arrow keys.
            LiquidSnake88 Level 1

            Thanks for samples, this is very kind ; p

             

            Hovewer you are doing everything almost exactly as I'am doing. Tou are using mySymbol.x++ which means your translation speed is 1. Also I'am aware that rising frame rate will result in smoother animations, but this is not the point. So once again, my flash applications suffer from two problems:

            1) Animations are not smooth. You can see this crealrly in here: http://www.kirupa.com/developer/actionscript/hittest.htm  , go back to the very bottom of the page, there is an animation window, look at the smallest circle. It looks like its blinking. 

            2) Moving symbols with arrow keys with the method i've presnted in the first post (the same method that infeter uses ). Moved symbol is randomly stopping for the very (very very) short amount of time. You can easily spot this in infeter sample.

             

            Many sample applications i've seen suffer from those issues. and nobody seems to see the problem, so maybe I am delusional? ; p

             

            cheers and thank for help

            • 3. Re: Artifacts when moving object with arrow keys.
              infeter Level 1

              You are welcome. I understand now. I don't see blinking you mentioned because I have a more powefull computer. I mean that my dedicated and integrated video cards are better. In order to achieve the same on your or slower computers you will need to investigate Direct/GPU acceleration via Flash Player. Google for it. Here are some examples:

               

              denis3197.JPG

               

              denis3198.JPG

              1 person found this helpful