New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCClippingNode not working on iOS and Mac #97

Open
kjpou1 opened this Issue Jan 12, 2015 · 6 comments

Comments

Projects
None yet
4 participants
@kjpou1
Member

kjpou1 commented Jan 12, 2015

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

This comment has been minimized.

Member

kjpou1 commented Feb 16, 2015

This is also no longer working on Windows.

@kjpou1

This comment has been minimized.

Member

kjpou1 commented Jun 17, 2015

Issue reported here MonoGame/MonoGame#3943

@juliengomes

This comment has been minimized.

juliengomes commented Mar 6, 2016

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...

@JuanuMusic

This comment has been minimized.

JuanuMusic commented Jul 9, 2017

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?

@juliengomes

This comment has been minimized.

juliengomes commented Jul 9, 2017

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

@vchelaru

This comment has been minimized.

vchelaru commented Jul 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment