Game Development Community

Is Masking possible with TGB?

by Ecliptic · in iTorque 2D · 02/23/2009 (5:51 pm) · 2 replies

Is it possable to use an image as a mask in side of TGB?

Thanks :D

*Edit nevermind guys I think I found one.

setRenderMasks(%groupMask, %layerMask)

#1
02/23/2009 (6:55 pm)
Hmm getting a console dialog that says it doesn't recognize the setRenderMasks command.

%mask = new t2dStaticSprite()
	{
		sceneGraph = %this;
		imageMap = "MaskConfig";
		class = "Masker"; // the class that will be associated with the object
		layer = 0; // the render layer
		size = "25 25"; // the size of the object
		position = "5 5";
	};
	
//Create a SimSet for the Mask group..
	$MaskSet = new SimSet();
	$MaskSet.add(%mask);
	
%Image = new t2dStaticSprite()
	{
		sceneGraph = %this;
		imageMap = "MaskConfig";
		class = "Image"; // the class that will be associated with the object
		layer = 0; // the render layer
		size = "25 25"; // the size of the object
		position = "-2 5";
	};


%mask.setRenderMask(BIT($MaskSet), BIT(0));

Any idea what is causing it? Or am I using the command wrong.

Thanks guys
Dane
#2
02/23/2009 (8:07 pm)
Yes you use it wrong. The first bit is 0 - 31 coresponding to the groups you can assign in the editor. You can not use a simset as a flag.

It will not offer you to mask stuff away with images if that is your target. It only defines which objects are rendered and which not.

if you want to use an image as a mask, just put it onto the topmost layer, spanning all screen and ensure that the stuff it is meant to cut is black and the rest white. if you then set the blending to a multiplicative one, it will make the stuff in black vanish.