The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 3 of 3

Thread: Problems with beginBitmapFill

  1. #1

    Problems with beginBitmapFill

    Hi everyone,

    I've been having some problems with "beginBitmapFill"; I simply want to use it to draw a single, un-tiled image at a certain point on the screen, like so:

    Code:
        graphics.beginBitmapFill(bitmap, null, false, false);
        graphics.drawRect(100, 100, test_image.width, test_image.height);
        graphics.endFill();
    The problem is that if you set the "tile" value in beginBitmapFill to false, then it will only draw the image once, at (0, 0). Is there anyway to offset the drawing of the image to a specific point (in my case (100, 100))? Thanks for reading, hope it's not too much of a lame question!

    Cheers,

    Mike.

  2. #2
    No worries its confusing for sure... Esp the "Matrix" class... Luckily we have a few cool shortcut functions that make it easier for us... In this case you want to use translate. The Matrix class basically allows us to transform the bitmap before pasting it where we want it... Try this then make the changes as necessary to suit your needs.

    Code:
        import flash.geom.*;
        var _mtx:Matrix = new Matrix()
        _mtx.translate(_xmouse,_ymouse);
        graphics.beginBitmapFill(bitmap, _mtx, false, false);
        graphics.drawRect(100, 100, test_image.width, test_image.height);
        graphics.endFill();
    Quote Originally Posted by megadev View Post
    Hi everyone,

    I've been having some problems with "beginBitmapFill"; I simply want to use it to draw a single, un-tiled image at a certain point on the screen, like so:

    Code:
        graphics.beginBitmapFill(bitmap, null, false, false);
        graphics.drawRect(100, 100, test_image.width, test_image.height);
        graphics.endFill();
    The problem is that if you set the "tile" value in beginBitmapFill to false, then it will only draw the image once, at (0, 0). Is there anyway to offset the drawing of the image to a specific point (in my case (100, 100))? Thanks for reading, hope it's not too much of a lame question!

    Cheers,

    Mike.

  3. #3
    Thanks shanimal, that's sorted it now. I come from a J2ME / C++ background, so I often feel like I'm trying to get round Flash's "features". ;-) In this case I just wanted to draw a sprite at an x, y screen co-ordinate without having to setup a new sprite and use addChild, as you probably should do. However, do you think that drawing sprites using a transformed matrix and beginBitmapFill is particularly slow? Is it frowned upon amongst Flash programmers? Anyway, thanks for your help - this technique will come in very handy. :-)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012