Fork me on GitHub
Not signed in (Sign In)

Welcome, Guest

Want to take part in these discussions? Sign in if you have an account, or apply for one below

    • CommentAuthorweasello
    • CommentTimeApr 18th 2011 edited
     
    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 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!
    • CommentAuthorRichard
    • CommentTimeApr 20th 2011
     
    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 mask where it is to scroll the scene around.

    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)