Be a Supporter!

Masks Using Drawing Api

  • 296 Views
  • 5 Replies
New Topic Respond to this Topic
Randomini
Randomini
  • Member since: Jul. 7, 2006
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Masks Using Drawing Api 2009-02-22 05:34:27 Reply

Sup Newgrounders.
I'm still working on alittle game I started a while ago (view Here). The way I achieve the rolling effect is by using Flash's Drawing API to mask the rotating background colours. The problem is, I also want to draw lines around the blob, and connecting the blob to the platform above it. If I do not mask it, then I can get these to appear, but as it is the API seems to only draw one thing - the mask for the blob or the lines around it. Is there any way to show both of these?

This script is in the root timeline and tells Flash to draw in two MCs: the masked one which covers the blob and the lines around it. Here's the code on the Root:

this.createEmptyMovieClip("blobdone",1)
this.createEmptyMovieClip("blobmask",2)
this.onEnterFrame = function() {
blobdone.clear();
blobdone.lineStyle(1,0x0000FF, 70)
blobdone.moveTo(up._x,up._y);
blobdone.lineTo(upright._x,upright._y);
blobdone.lineTo(right._x,right._y);
blobdone.lineTo(downright._x,downright._
y);
blobdone.lineTo(down._x,down._y);
blobdone.lineTo(downleft._x,downleft._y)
;
blobdone.lineTo(left._x,left._y);
blobdone.lineTo(upleft._x,upleft._y);
blobdone.lineTo(up._x,up._y);
blobdone.lineStyle(2,0xFF0000,50)
blobdone.lineTo(platform._x,platform._y)
;
updateAfterEvent;
}

this.onEnterFrame = function() {
blobmask.clear();
blobmask.lineStyle(0,0x0000FF)
blobmask.moveTo(up._x,up._y);
blobmask.beginFill(0x00FFFF, 50)
blobmask.lineTo(upright._x,upright._y);
blobmask.lineTo(right._x,right._y);
blobmask.lineTo(downright._x,downright._
y);
blobmask.lineTo(down._x,down._y);
blobmask.lineTo(downleft._x,downleft._y)
;
blobmask.lineTo(left._x,left._y);
blobmask.lineTo(upleft._x,upleft._y);
blobmask.lineTo(up._x,up._y);
updateAfterEvent;
}

And then there's the movieclip under, which simply says:

onClipEvent(enterFrame){
this.setMask("blobmask");
}

I know the script is a bit long, but I hope someone can help me.
Thanks in Advance!
Randomini


BBS Signature
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to Masks Using Drawing Api 2009-02-22 06:38:10 Reply

Well I'm not sure how it works with two this.onEnterFrame
Also, I think a mask has to be a fill rather than a line - not sure how relevant that is
Your other choice of course is just to add another createEmptyMovieClip at a higher depth and draw the lines in that


- - Flash - Music - Images - -

BBS Signature
Randomini
Randomini
  • Member since: Jul. 7, 2006
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Masks Using Drawing Api 2009-02-22 15:26:41 Reply

At 2/22/09 06:38 AM, Denvish wrote: Your other choice of course is just to add another createEmptyMovieClip at a higher depth and draw the lines in that

That's just the problem - that's what I'm doing, and it's coming up the way you see in the Demo! I don't know what I'm doing wrong!


BBS Signature
LeechmasterB
LeechmasterB
  • Member since: Apr. 1, 2005
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to Masks Using Drawing Api 2009-02-22 15:57:55 Reply

Sounds like you are masking away the lines somehow, may be you could just make the mask wider by the amount of the line thickness.

Randomini
Randomini
  • Member since: Jul. 7, 2006
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Masks Using Drawing Api 2009-02-22 22:21:13 Reply

At 2/22/09 03:57 PM, LeechmasterB wrote: Sounds like you are masking away the lines somehow, may be you could just make the mask wider by the amount of the line thickness.

Tried it, didn't work.


BBS Signature
Randomini
Randomini
  • Member since: Jul. 7, 2006
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Masks Using Drawing Api 2009-02-22 23:05:11 Reply

Don't worry, I got it working. I had to change the root code to this:

this.createEmptyMovieClip("blobdone",1)
this.createEmptyMovieClip("blobmask",2)
this.onEnterFrame = function() {
blobdone.clear();
blobdone.lineStyle(1,0x650101, 70)
blobdone.moveTo(up._x,up._y);
blobdone.lineTo(upright._x,upright._y);
blobdone.lineTo(right._x,right._y);
blobdone.lineTo(downright._x,downright._
y);
blobdone.lineTo(down._x,down._y);
blobdone.lineTo(downleft._x,downleft._y)
;
blobdone.lineTo(left._x,left._y);
blobdone.lineTo(upleft._x,upleft._y);
blobdone.lineTo(up._x,up._y);
blobdone.lineStyle(2,0x002966,50)
blobdone.lineTo(platform._x,platform._y)
;
blobBG.setMask("blobmask");
blobmask.clear();
blobmask.lineStyle(0,0x0000FF)
blobmask.moveTo(up._x,up._y);
blobmask.beginFill(0x00FFFF)
blobmask.lineTo(upright._x,upright._y);
blobmask.lineTo(right._x,right._y);
blobmask.lineTo(downright._x,downright._
y);
blobmask.lineTo(down._x,down._y);
blobmask.lineTo(downleft._x,downleft._y)
;
blobmask.lineTo(left._x,left._y);
blobmask.lineTo(upleft._x,upleft._y);
blobmask.lineTo(up._x,up._y);
updateAfterEvent;
}

And now it works fine!


BBS Signature