如何在 cocos2d 项目中放置永久视图(用于广告)
我有一个 cocos2d 项目,其中有一些场景(家庭场景、关卡选择场景、游戏场景、信用场景等),每个场景都有一个广告横幅视图。
我正在每个场景中创建横幅视图,但我不喜欢这样(我希望广告保持在原位,直到它自行重新加载)。
那么,如何才能让广告始终显示在屏幕上并且场景发生变化,而无需在每次场景变化时重新加载广告视图呢?
有可能吗?
I have a cocos2d project with some scenes (home scene, level selection scene, game scene, credit scene and so on) and I have an ad banner view in every scene.
I'm creating the banner view in every scene but I don't like this (I want the ad stay in place until it reloads by itself).
So how can I have the ads always on screen and scenes changes without reloading the ad view at every scene change?
Is that possibile?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,只需将横幅视图添加到:
这当然是假设您的bannerView 是一个UIKit 视图,就像大多数横幅一样。如果你的横幅视图实际上是一个精灵或其他 cocos2d 节点,那么除了继续做你已经做的事情之外,你别无选择。确保视图保持永久的唯一方法是修改 CCDirector,具体来说,replaceScene 方法必须从当前场景中删除视图并将其添加回下一个场景。
Yes, simply add the banner view to:
This is of course assuming that your bannerView is a UIKit view, as most banners are. If your banner view is actually a sprite or other cocos2d node, you have little choice other than keep doing what you already do. The only way to ensure the view stays permanent is to modify CCDirector, specifically the replaceScene method would have to remove the view from the currentscene and add it back in to the next scene.