CocosSharp icon indicating copy to clipboard operation
CocosSharp copied to clipboard

CCClippingNode not working on iOS and Mac

Open kjpou1 opened this issue 11 years ago • 6 comments

This has never worked on iOS or Mac because of missing functionality from the MonoGame side of things. If the functionality is there then it is not working correctly nor the same as for windows.

Reference http://forums.xamarin.com/discussion/30693/cant-get-ccclippingnode-to-work-has-anyone#latest

kjpou1 avatar Jan 12 '15 08:01 kjpou1

This is also no longer working on Windows.

kjpou1 avatar Feb 16 '15 09:02 kjpou1

Issue reported here https://github.com/mono/MonoGame/issues/3943

kjpou1 avatar Jun 17 '15 04:06 kjpou1

It's not working indeed.

I made a little test, inspired by the code there http://stackoverflow.com/a/18736230/509981 to make a part of a layer transparent.

C++ version using cocos2d-x

Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin();
addChild(LayerColor::create(Color4B(122, 144, 0, 255), visibleSize.width, visibleSize.height));

//this is the layer that we want to "cut"
Layer *layer = Layer::create();
Sprite* pSprite = Sprite::create("ball.png");
pSprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
layer->addChild(pSprite, 0);

//we need to create a ccnode, which will be a stencil for ccclipingnode, draw node is a good choice for that
DrawNode * stencil = DrawNode::create();
stencil->drawSegment(Vec2(0, 0), Vec2(visibleSize.width, visibleSize.height), 20, Color4F(0, 0, 0, 255));

//CCClipingNode show the intersection of stencil and theirs children
ClippingNode *cliper = ClippingNode::create(stencil);
//you want to hide intersection so we setInverted to true
cliper->setInverted(true);
cliper->addChild(layer);
addChild(cliper);

Results

simulator screen shot 06 mar 2016 09 56 10

C# version using CocosSharp

this.AddChild(new CCLayerColor(new CCSize(1024,768),new CCColor4B(122,144,0,255)));

//this is the layer that we want to "cut"
CCLayer layer = new CCLayer();
CCSprite pSprite = new CCSprite("ball.png");
pSprite.Position = new CCPoint(512, 386);
layer.AddChild(pSprite);

CCDrawNode stencil = new CCDrawNode();
stencil.DrawSolidCircle(new CCPoint(0, 0), 20, new CCColor4B(0, 0, 0, 255));
stencil.DrawLine(new CCPoint(0,0),new CCPoint(1024, 768),20,new CCColor4B(0, 0, 0, 255));

CCClippingNode cliper = new CCClippingNode(stencil);
cliper.Inverted = true;
cliper.AddChild(layer);
this.AddChild(cliper);

Results

simulator screen shot 06 mar 2016 10 09 15

What worries me the most is that it's a more than a year old bug and it's still not fixed...

ghost avatar Mar 06 '16 09:03 ghost

Hey Guys. I'm on version 1.7.1 (latest as of today) and the CCClippingNode class is still not working. Any news on this? Maybe a workaround?

JuanuMusic avatar Jul 09 '17 09:07 JuanuMusic

This is the answer I got from miguel de icaza few months ago https://twitter.com/juliengomes/status/786905026757263360

ghost avatar Jul 09 '17 14:07 ghost

CocosSharp seems to be down but FlatRedBall is a good alternative for 2D cross-platform game dev using C# (also based on MonoGame): www.flatredball.com

Hope that helps.

--Victor Chelaru-- 801 391 5271 hangouts: [email protected] skype: armysarj www.flatredball.com

On Sun, Jul 9, 2017 at 8:35 AM, Julien Gomès [email protected] wrote:

This is the answer I got from miguel de icaza few months ago https://twitter.com/juliengomes/status/786905026757263360

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mono/CocosSharp/issues/97#issuecomment-313923662, or mute the thread https://github.com/notifications/unsubscribe-auth/AAsiH8io9tqP4W9-C3VGsBB1LDKljY4oks5sMOVPgaJpZM4DRCTc .

vchelaru avatar Jul 09 '17 16:07 vchelaru