Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
241 views
in Technique[技术] by (71.8m points)

iphone - Making a SKScene's background transparent not working... is this a bug?

Is there a way to make a SKScene's background transparent and present that scene over another one seeing thru the transparency.

The idea is to have the background of the presented scene like this:

self.backgroundColor = [SKColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.5f];

what would allow to see the scene behind darken. But doing this is not working. Background is presented completely opaque.

Is there a way to do that?

question from:https://stackoverflow.com/questions/18894493/making-a-skscenes-background-transparent-not-working-is-this-a-bug

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In iOS 8, you can set the scene's SKView to allow transparency and set the scene's background color to have transparency. Then views behind the SKView will be seen.

UIView *parentView = ...;
[parentView addSubview:backgroundView];
[parentView addSubview:skViewWithScene];
skViewWithScene.allowsTransparency = YES;
scene.backgroundColor = [UIColor clearColor];
[skViewWithScene presentScene:scene];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...