如何在Cocos2d中添加不受场景转换影响的全局CCLayer? [英] How to add global CCLayer which is not affected by scene transitions in Cocos2d?

查看:56
本文介绍了如何在Cocos2d中添加不受场景转换影响的全局CCLayer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不受场景转换影响的Cocos2d中添加全局图层?

Is it possible to add global layer in Cocos2d, which is not affected by scene transitions?

如我所见,它应该位于所有场景层次之上.

As I can see, it should be above all scenes hierarchy.

在Cocos2d论坛上有一个简短的讨论,但没有答案: http://www.cocos2d-iphone.org/forum/topic/8071

There's an old and short discussion on Cocos2d forum, but there's no answer: http://www.cocos2d-iphone.org/forum/topic/8071

UPD.通过场景过渡"是指通过动画场景过渡".

UPD. 'by scene transitions' I mean 'by animated scene transitions'.

推荐答案

您可以使用CCDirector的notificationNode属性来放置CCNode(即CCLayer,CCLabel等),该CCNode即使在过渡期间也将保留在场景上方.像这样:

You can use the notificationNode property of CCDirector to place a CCNode (ie.CCLayer, CCLabel, etc.) that will remain above scenes, even during transitions. Something like this:

CCLayer *layer = [CCLayer node];
CCLabelTTF *label = [CCLabelTTF labelWithString:@"Test" fontName:@"Marker Felt" fontSize:32];
[layer addChild:label];
[[CCDirector sharedDirector] setNotificationNode:layer]; // Layer should be placed here
[layer onEnter]; // Schedule for updates (ie. so that CCActions will work)

这是出于通知目的(广告等),因此我不建议您尝试从该节点上做任何花哨的事情.

It's meant for notification purposes (ads, etc.) so I wouldn't suggest trying to do anything too fancy from this node.

这篇关于如何在Cocos2d中添加不受场景转换影响的全局CCLayer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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