더블 버퍼를 사용하여 간단한 플래시 게임을 개발하여 애니메이션을 그려 봅니다.더블 버퍼 캔버스를 사용한 간단한 애니메이션이 부드럽 지 않다.
Event.ENTER_FRAME이 (가) 발생하면 다시 그리기가 발생합니다.
이중 버퍼링에 사용되는 후방 버퍼는 BitmapData 유형입니다.
애니메이션은 매우 간단합니다. 20x20 픽셀의 비트 맵을 x 좌표가 증가하는 백 버퍼에 그려 내 캔버스의 왼쪽에서 오른쪽으로 부드럽게 움직여야합니다. 이것은 근본적으로 잘 작동하지만, 면밀히 살펴보면이 운동에서 큰 혼란을 볼 수 있습니다. 프레임 속도와 관련이없는 것 같습니다. 60도를 넘기 때문에 움직이지 않습니다. 부드러운 움직임의 중단은 애니메이션에서는 허용되지 않지만 이중 버퍼링에 아무런 문제가 없었 음을 확신합니다. m는 이러한 경우가 있다면이 플래시 플레이어 문제 또는 뭔가 ... 나는 매우 안심이 될 수 겁
간단한 애니메이션을 보여주는 SWF를 살펴 준비해주십시오
https://dl.dropbox.com/u/55967135/test.swf
을(동작이 두 프레임 사이의 시간을 기반으로 할 때 애니메이션의 중단도 사라지지 않습니다. 이제는 프레임 당 상수가 2 픽셀입니다.)
나는 위의 SWF에 대한 전체 소스 코드를 포함하여 매우 가벼운 플래시 빌더 프로젝트를 업로드 한: https://dl.dropbox.com/u/55967135/test.zip
public function enterFrame():void
{
// Calculate the time since the last frame (NOT USED IN THE EXAMPL PROGRAM)
var thisFrame : Date = new Date();
var dT : Number = (thisFrame.getTime() - lastFrame.getTime())/1000.0;
lastFrame = thisFrame;
// erase backBuffer
backBuffer.fillRect(backBuffer.rect, 0xFFFFFFFF);
// set new postion of the small testimage
if (this.pos > 600 || this.pos < 0) {
this.direction = !this.direction;
}
// increase/decrease vertical position
if (this.direction) {
this.pos += 2;
} else {
this.pos -= 2;
}
//trace(pos);
// draw small test image at postion "offset"
backBuffer.copyPixels( this.testGraphic.bitmap.bitmapData,
this.testGraphic.bitmap.bitmapData.rect,
new Point(pos, 0.0));
}
enterFrame이()는 doublebuffering을 처리하는 내 수업 GraphicsController의 방법이다.
도움말을 크게 감상 할 수 public function enterFrame(event:Event):void
{
GraphicsController.Instance.enterFrame();
myCanvas.graphics.clear();
myCanvas.graphics.beginBitmapFill(GraphicsController.Instance.backBuffer, null, false, false);
myCanvas.graphics.drawRect(0, 0, this.width, this.height);
myCanvas.graphics.endFill();
stage.invalidate();
}
가 크롬에 완벽하게 나를 위해 부드러운 당신에게