使SKScene的背景透明不起作用......这是一个错误吗? [英] Making a SKScene's background transparent not working... is this a bug?

查看:630
本文介绍了使SKScene的背景透明不起作用......这是一个错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让SKScene的背景透明,并通过透明度将该场景呈现在另一个场景上。

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?

推荐答案

在iOS 8中,您可以设置场景的SKView以允许透明度并将场景的背景颜色设置为具有透明度。然后会看到SKView背后的观点。

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];

这篇关于使SKScene的背景透明不起作用......这是一个错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆