Skip navigation
LiquidSnake88
Currently Being Moderated

Artifacts when moving object with arrow keys.

Jun 30, 2012 8:00 AM

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

 
Replies
  • Currently Being Moderated
    Jun 30, 2012 4:06 PM   in reply to LiquidSnake88

    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!

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 1, 2012 2:54 PM   in reply to LiquidSnake88

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points