Vsync in Flex/Flash/AS3?
Posted
by oshyshko
on Stack Overflow
See other posts from Stack Overflow
or by oshyshko
Published on 2009-06-12T23:13:40Z
Indexed on
2010/03/14
22:45 UTC
Read the original article
Hit count: 522
I work on a 2D shooter game with lots of moving objects on the screen (bullets etc).
I use BitmapData.copyPixels(...) to render entire screen to a buffer:BitmapData. Then I "copyPixels" from "buffer" to screen:BitmapData. The framerate is 60.
private var bitmap:Bitmap = new Bitmap();
private var buffer:Bitmap = new Bitmap();
private function start():void {
addChild(bitmap);
}
private function onEnterFrame():void {
// render into "buffer"
// copy "buffer" -> "bitmap"
}
The problem is that the sprites are tearing apart: some part of a sprite got shifted horizontally.
It looks like a PC game with VSYNC turned off.
Did anyone solve this problem?
UPDATE: the question is not about performance, but about getting rid of screen tearing.
[!] UPDATE: I've created another question and here you may try both implementations: using Flash way or BitmapData+copyPixels()
© Stack Overflow or respective owner