A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Quick question 'bout bitmapData and tile-based

  1. #1
    Lunatic Baukereg's Avatar
    Join Date
    Nov 2000
    Location
    Lowlands
    Posts
    853

    Quick question 'bout bitmapData and tile-based

    Just a quick question, I have decided to learn myself to create a tile-based engine not based on gotoAndStop tiles but based on tiles being attached as bitmapData. Everything is working well so far, this is the png with the tiles:



    Just 3 tiles, dirt grass and water. The testmap is only 6 by 4 so far, and you can use the arrow keys to scroll around:

    http://www.planetbauke.com/test/engine.html

    There's a map_bmd (bmd = bitmapData) that contains the entire map, and there's a view_bmd that copy's the 80x80 canvas that is the visible area of the map. It's attached then to view_mc. That should make sense doesnt it?

    But as you can see, once you cross the border of the map, you get this magic mushroom kind of effect, and although I like mushrooms I'd rather have just a black background being visible. This is the function activated when you press a key:

    code:
    function updateView() {
    var rect = new Rectangle(viewX, viewY, viewWidth, viewHeight);
    var point = new Point(0,0);
    view_bmd.copyPixels(map_bmd, rect, point);
    }



    As you can see, I copy the visible canvas of the map_bmd once again to view_bmd without clearing view_bmd first. How can I clear view_bmd? Or is this not the best way to handle and update the view?


    Btw, here's a as file with all the actionscript from the first frame of the fla. Anyone interested and/or willing to give feedback, check it out:
    http://www.planetbauke.com/test/firstframe.as
    Last edited by Baukereg; 06-17-2007 at 01:21 PM.

  2. #2
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140
    function updateView() {

    var rect = new Rectangle(viewX, viewY, viewWidth, viewHeight);

    var point = new Point(0,0);

    view_bmd.fillRect(rect, 0x000000)

    view_bmd.copyPixels(map_bmd, rect, point);

    }
    lather yourself up with soap - soap arcade

  3. #3
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,379
    Heh, that looks like a familiar function...
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  4. #4
    Lunatic Baukereg's Avatar
    Join Date
    Nov 2000
    Location
    Lowlands
    Posts
    853
    It that so, haha, seems I'm on the right way then. This topic of yours was a big help:

    http://board.flashkit.com/board/hist.../733499-1.html

    Edit:

    Little correction, it needs to be:

    view_bmd.fillRect(new Rectangle(0, 0, viewWidth, viewHeight), 0x000000);
    Last edited by Baukereg; 06-18-2007 at 02:25 AM.

  5. #5
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,379
    Good, I'm always glad to see that my thread can help others.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center