Copy link to clipboard
Copied
Hi
I have a spirte circSprite that I draw on a large bitmap drawingBitmap.
drawingBitmapData = new BitmapData(800, 600, true,0);
drawingBitmap = new Bitmap(drawingBitmapData);
stage.addChild(drawingBitmap);
var circSprite:Sprite = new Sprite();
circSprite.graphics.beginFill(0xFF0000,0);
circSprite.graphics.drawRect(0,0,160,160);
circSprite.graphics.endFill();
circSprite.graphics.beginFill(0xFF00FF,1);
circSprite.graphics.drawCircle(40,40,40);
circSprite.graphics.endFill();
var mat:Matrix = new Matrix();
drawingBitmapData.drawWithQuality(circSprite,mat,null,null, null,true,StageQuality.MEDIUM);
I would like to move the circSpirte to a different position ( 100,100 ) - how can I do that?
Thanks!
Rolf
update the matrix:
var rect:Rectangle=new Rectangle(0,0,800,600);
var bgColor:uint = 0xffffff; //<- use your stage color
mat.tx+=3;
drawingBitmapData.fillRect(rect,bgColor); //<- to make it look like the previously drawn object(s) were erased
drawingBitmapData.drawWithQuality(circSprite,mat,null,null, null,true,StageQuality.MEDIUM);
Copy link to clipboard
Copied
update the matrix:
var rect:Rectangle=new Rectangle(0,0,800,600);
var bgColor:uint = 0xffffff; //<- use your stage color
mat.tx+=3;
drawingBitmapData.fillRect(rect,bgColor); //<- to make it look like the previously drawn object(s) were erased
drawingBitmapData.drawWithQuality(circSprite,mat,null,null, null,true,StageQuality.MEDIUM);
Copy link to clipboard
Copied
Hi kglad
Thanks, that worked! Had to remove this part of the code because otherwice the circle was cut off. It kinda working as a mask?
circSprite.graphics.beginFill(0xFF0000,0);
circSprite.graphics.drawRect(0,0,160,160);
circSprite.graphics.endFill();
Anyway, thanks a lot
Copy link to clipboard
Copied
you're welcome.
p.s. rob's suggestion would work too but is not the approach you should take if you wanted to "animate" your circle. the code i suggested is the typical blitting code used to make it appear a blitted object is animated.
Copy link to clipboard
Copied
The drawCircle function takes 3 arguments, the x position, the y position and the radius, so if you want the circle at 100, 100, then just change that line to:
circSprite.graphics.drawCircle(100,100,40);
Find more inspiration, events, and resources on the new Adobe Community
Explore Now