开发者

AS3 Stop flickering of moving object

I have a ball moving around the screen, position updated on ENTER_FRAME. My problem is that there is a considerable amount of flicker going on. I have thought 开发者_高级运维about using something like TweenLite to move the ball but as the position is being updated frame-to-frame I don't think that will work. I have increased the frame rate and reduced the speed the ball is travelling (and vice-versa) but that didn't help.

What can I do to reduce (preferably stop) the flickering?

[edit] Here is the update function. Ball is a MovieClip.

public function update(e:Event):void {
    this.x += moveX;
    this.y += moveY;
}


If you're code is something like this:

private function onEnterFrame(e:Event){ derp.x += 10; }

there should be no flicker if derp is a movieclip. There might be fickering if you are using bitmapData on Bitmaps (depending on your logic)

but if you are using a movieclip like above, then no flicker should occur; it's probably your computer.

Upload you .swf so we can get a better picture of whats going on.


The 'flickering' was being caused by my high frame-rate and moving the 'ball' several pixels at once. The result is that parts of the ball were being rendered in a different location to other parts of the ball per frame. To fix this I am now moving the ball only one pixel at a time and adjusting the frame-rate to control the speed of the ball.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜