Flint Particle System Forum - 2D camera or equivalent movement? ALSO: BitmapRenderer doesn't accept negatives Sun, 11 Dec 2011 10:04:35 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher 2D camera or equivalent movement? ALSO: BitmapRenderer doesn't accept negatives http://flintparticles.org/forum/comments.php?DiscussionID=473&Focus=1603#Comment_1603 http://flintparticles.org/forum/comments.php?DiscussionID=473&Focus=1603#Comment_1603 Mon, 18 Apr 2011 03:59:31 +0100 weasello
I have a large game that spans a top-down map of dimensions -5000 -> 5000 X and -5000->5000 Y.

On this map, the viewport is 640x480 and scrolls the map by moving map.x and map.y to slide it under the viewport.

On this map there are explosions - and I'm trying to use Flint for them. I want the explosions to remain married to a map coordinate and not the viewport (otherwise an explosion would scroll around the map with the view).

I've tried to update:

renderBitmap.canvas = new Rectangle(viewportx, viewporty, viewportx+width, viewporty+width)

But the values there sometimes go negative.. eg: -1000, -1000, -600, -600

And this seems to throw the error "Invalid Bitmap Data."

I was looking for other solutions to "moving" the rendered viewport in Flint, and I came across the "Camera" class.. but it doesn't seem to be available for the 2D libraries.

I also want to avoid making the render area 10000x10000 and offsetting it by a certain amount, as that would be horrible to render :)

advice please! ]]>
2D camera or equivalent movement? ALSO: BitmapRenderer doesn't accept negatives http://flintparticles.org/forum/comments.php?DiscussionID=473&Focus=1611#Comment_1611 http://flintparticles.org/forum/comments.php?DiscussionID=473&Focus=1611#Comment_1611 Wed, 20 Apr 2011 08:40:38 +0100 Richard
Your solution with modifying the canvas should also work (and will likely be more efficient if you're not moving the map very often). The canvas property is a Rectangle. It's constructor takes the x and y and the width and height - in your example you're setting the width and height to negative numbers and that's what causes the error. Try

renderBitmap.canvas = new Rectangle(viewportx, viewporty, width, height) ]]>