mono / CocosSharp

CocosSharp is a C# implementation of the Cocos2D and Cocos3D APIs that runs on any platform where MonoGame runs.
492 stars 159 forks source link

CCClippingNode not working on iOS and Mac #97

Open kjpou1 opened 9 years ago

kjpou1 commented 9 years ago

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 commented 9 years ago

This is also no longer working on Windows.

kjpou1 commented 9 years ago

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

ghost commented 8 years ago

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 commented 7 years ago

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?

ghost commented 7 years ago

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

vchelaru commented 7 years ago

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: VicChelaru@gmail.com skype: armysarj www.flatredball.com

On Sun, Jul 9, 2017 at 8:35 AM, Julien Gomès notifications@github.com 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 .