Results 1 to 3 of 3
Thread: Problems with beginBitmapFill
-
February 5th, 2008, 12:30 PM #17Registered User
postsProblems 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:
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!Code:graphics.beginBitmapFill(bitmap, null, false, false); graphics.drawRect(100, 100, test_image.width, test_image.height); graphics.endFill();
Cheers,
Mike.
-
February 6th, 2008, 06:28 PM #21Registered User
postsNo 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();
-
February 7th, 2008, 10:43 AM #37Registered User
postsThanks 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. :-)

Reply With Quote


Bookmarks