• Advertisement
Sign in to follow this  

Flash Blitting Flicker

This topic is 1663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Edit: Sorry I meant to post this in Beginners forum.

I am creating a platformer where the entire game is blitted. The tile map seemed to be fine, however certain tiles with transparent pixels flicker very badly when the screen moves, appearing to change brightness rapidly, whilst other parts remain okay (I think).

Please check out this little demo to see the effect (use WASD to move around).

http://www.dampdogdev.com/devDemos/rngFlicker/flicker.html

I've tried rounding the exact render position, flooring it, and double buffering but nothing I've tried seems to affect it.

Share this post


Link to post
Share on other sites
Advertisement

I see the flicker with the tiles that look like fencing. No flicker in the rest that I can see. Game loop/ rendering code?

Share this post


Link to post
Share on other sites

Edit: Sorry I meant to post this in Beginners forum.

I am creating a platformer where the entire game is blitted. The tile map seemed to be fine, however certain tiles with transparent pixels flicker very badly when the screen moves, appearing to change brightness rapidly, whilst other parts remain okay (I think).

Please check out this little demo to see the effect (use WASD to move around).

http://www.dampdogdev.com/devDemos/rngFlicker/flicker.html

I've tried rounding the exact render position, flooring it, and double buffering but nothing I've tried seems to affect it.

Can we have some more information. For example, which language, library, API, etc.

 

It'd also be helpful to see the code.

Share this post


Link to post
Share on other sites

Cleaned up a bit here it is. Language is Actionscript 3, only libraries used are Box2D for physics/collision, the rest is my own or standard Flash stuff.

// On Frame draw call in Main
public function Render():void
{
	canvas.lock();
	canvas.fillRect(canvas.rect, 0xff000000);
	_manager.currentState.Render(canvas);
	canvas.unlock();
}

// In GameState
public function Render(canvas:BitmapData):void
{
	var mapRendPoint:Point = _gameModel.mapRenderPoint;
	// Position is taken from the box2D physics position of a camera entity tracking the player.
	// Subtract half screen width to get the top left point of the screen.
	var scrX:Number = _gameModel.camera.position.x * Main.PIXELS_PER_METRE - screenInfo.halfWidth;
	var scrY:Number = _gameModel.camera.position.y * Main.PIXELS_PER_METRE - screenInfo.halfHeight;
	scrX = Math.round(scrX);
	scrY = Math.round(scrY);
	mapRenderPoint.x = scrX;
	mapRenderPoint.y = scrY;
	
	// Render point is kept within the bounds of the tile map
	_gameModel.TileMap.CapRenderPoint(mapRenderPoint);
	
	// TileMap is given map position and adds every Tile to be drawn to the Draw List.
	_gameModel.TileMap.Render(mapRenderPoint);
	
	/* Game objects are added to the list */
	
	// display list is called, this will actually run the calls to copy to canvas. draw list is then wiped
	_blitter.RenderFrame(canvas, mapRenderPoint);
}

// In Tile class, called from _blitter after TileMap has added all the tiles to be drawn
public function Render(canvas:BitmapData, topLeft:Point):void
{
    // Translate to screen position
    _rendPosition.x = _position.x - topLeft.x;
    _rendPosition.y = _position.y - topLeft.y;
    // Draw
    canvas.copyPixels(_curFrame, _rendRect, _rendPosition, null, null, true);
}


Edited by zqf

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement