2
votes

I'm trying to get my campfire movie clip to mask over my night shadow movie clip, so it doesn't show the "darkness" of night by erasing that part of the movie clip. It erase's it but not just the size of the movie clip, it erase's all of it :D

I've tried placing it on level instead of in world.worldTiles and taking it out of the array but it still does the same thing. I've also tried placing it on the world.worldTiles[i] of the movie clip, still erase's the whole movie clip. I flipped the .mask = night around and it only shadows over the campfire model.

This is the code I'm using:

    public function addWorldObj(obj:MovieClip, c:Class, X:int, Y:int, w:Number, h:Number, f:int)
    {
        obj = new c();
        world.worldTiles.addChild(obj);
        obj.x = playerTileCoord.x + X;
        obj.y = playerTileCoord.y + Y;
        obj.width = w;
        obj.height = h;
        obj.gotoAndStop(f);
        if(obj.Name == "campfire"){
                obj.mask = night;
        }
        world.tilesInWorld.push(obj);
    }

The night shadow movieclip is just a giant black square thats alpha gets changed.

The campfire is an invisible square with an overhead campfire drawn inside it, the width and height of the campfire are the size of 1 square, it should be masking 1 square out of the nightShadow movieclip, but it mask all of it.

Here is a link to the game. http://www.fastswf.com/00CRfh4 The game starts out at .75 alpha counting upwards. You can click on the hammer at the bottom right of the screen to open the build menu (You can also click the "E" button which also kills you at the moment for testing purpose's) Once open click the campfire text and place it somewhere on the map and watch it mask away the whole night movieclip! :D

2
I think it will be very helpful if you showed an image of each MovieClip and an image of what the whole thing should look like because I can't visualize what you're trying to do.TreeTree
I added a link to the game and explained more about the movie clipsSniffle6
Am I understanding correctly that you are adjusting the alpha property of the mask? If so, you can't do that. Alpha properties are ignored on masks.Anil Natha
Well, im adjusting the alpha property of the large black square to imitate the sun setting. Your saying that it all disappears cause the alpha gets set to 0 when i mask it because im adjusting its alpha in my code?Sniffle6

2 Answers

1
votes

I'm assuming that the night movie clip is the size of the stage (maybe bigger), and by using it as the mask, it will disappear because masks are intended to be invisible. This is why it disappears when you make the call obj.mask = night. In addition, adjusting the alpha properties of a mask has no effect on that mask because as I mentioned, masks are invisible.

Now you have a few options:

  1. Implement something completely different than you already have to lighten the area around the campfire. By this I mean that if you want the area around the campfire to be lit and gradually fade to night as you move further away from the campfire.
  2. If you don't care about lightening the area around the campfire, but least have the campfire now look dimmed because of the night layer, perhaps you could try putting the campfire objects above the night layer.
1
votes

So the problem i was having is masking does not exactly do what i was wanting it too, instead i used BlendMode.Erase

    public var spr:Sprite = new Sprite();
    var msk:Sprite = new Sprite();


    private var gType:String;  
    private var matrix:Matrix;  

    private var bound:Sprite;



    public function addNight()
    {
        spr.alpha = .85;

        spr.graphics.beginFill(0x000000);
        spr.graphics.drawRect(0,0 ,800,600);
        spr.graphics.endFill();

        prnt.addChild(spr);

        spr.blendMode = BlendMode.LAYER;
    }



    public function addLight(x:int, y:int)
    {
        var gType:String = GradientType.RADIAL;  

        var matrix:Matrix = new Matrix();  
        matrix.createGradientBox(300,300,0,0,0);    

        var gColors:Array = [0xFFFFFF, 0x000000];  
        var gAlphas:Array = [.9,0];  
        var gRatio:Array = [0,255];  

        var bound:Sprite = new Sprite();  
        bound.graphics.beginGradientFill(gType,gColors,gAlphas,gRatio,matrix);  
        bound.graphics.drawCircle(150,150,150);
        bound.x = bound.y = 0;  

        bound.x = x;
        bound.y = y;
        bound.blendMode = BlendMode.ERASE;
        spr.addChild(bound);
    }