Flint Particle System Forum - 2D camera or equivalent movement? ALSO: BitmapRenderer doesn't accept negatives 2011-12-11T09:35:33+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & 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 2011-04-18T03:59:31+01:00 2011-04-20T08:41:08+01:00 weasello http://flintparticles.org/forum/account.php?u=486 Hey Gents, 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 ...
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 2011-04-20T08:40:38+01:00 2011-12-11T09:35:33+00:00 Richard http://flintparticles.org/forum/account.php?u=1 The BitmapRenderer is a sprite, so the easiest way to handle this is to set a mask on the renderer and move the mask around to show different regions of the scene, or move the renderer and leave the ...
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)]]>