iPhone Opengl 游戏有广告== fps 问题?

发布于 2024-10-03 11:34:52 字数 388 浏览 0 评论 0原文

我有一款游戏可以正常运行(大约 30fps),但是当我尝试实施广告时,fps 下降了。我尝试了 Greystripe 和 iAds,但结果相同(iAds 可能更糟)。平均 fps 几乎相同,但始终存在巨大的峰值(每秒 1-2 个峰值),并且游戏无法玩。

我想这是因为广告是在另一个视图中。我在某处读到,iPhone 上的 opengl 应用程序不喜欢有其他视图,但应用程序商店中有很多带有广告的游戏。他们是如何做到的?

我的实现应该没问题。我按照文档和样本的指示做了所有事情。我将 opengl 视图和 ad 视图作为应用程序窗口中的子视图,adview 位于 opengl 视图前面,从而覆盖了其中的一部分。这可能是问题所在吗?是否最好让 opengl 视图变小以留出广告空间,这样它们就不会重叠?您还有其他想法可能是错误的吗?

I have a game that runs fine as is (around 30fps), but fps went down the drain when I tried to implement ads. I tried Greystripe and iAds but with same result (iAds were maybe bit worse). Average fps is almost same, but there are huge spikes all the times (1-2 spikes per second) and game is unplayable.

I guess it is because ad is in another view. I read somewhere that opengl apps on iphone don't like having another views with them, but there is plenty of games with ads on app store. How do they do it?

My implementation should be ok. I did everything as documentation and samples told me. I have my opengl view and ad view as subviews in app window, adview being in front of opengl view and thus covering part of it. Could this be the problem? Is it better to make opengl view smaller to left space for ad so they don't overlap? Do you have any other ideas what could be wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

随遇而安 2024-10-10 11:34:52

Lope,我已经在此链接创建了一个要点,其中包含我编写的用于处理 iAd 的单例“AdManager”类使用cocos2d。当然,Cocos2d 位于 OpenGL 之上,我发现即使对于相对复杂的游戏,此代码也不会影响 FPS。

您必须对此进行一些修改才能与您的应用程序配合使用,更改 cocos2d 调用等,但这将为您提供 iAd 的异步加载,这应该有助于解决 FPS 问题。

要使用此类,请包含其标头并

[[AdManager sharedManager] attachAdToView:self.view];

在需要 iAd 的任何地方调用。广告将保持隐藏状态,直到广告加载,此时它们将在屏幕顶部弹出。 (该类适用于 iOS 4.0、4.1 和 4.2)。

另外,我应该补充一点,我有 cocos2d 在我称为“Cocos2DController”的整个 UIViewController 中运行。当我将广告附加到 cocos2d 视图时,我使用的是

[[AdManager sharedManager] attachAdToView:[[CCDirector sharedDirector] openGLView]];

“祝你好运!”

Lope, I've created a gist at this link with a singleton "AdManager" class I wrote to handle iAds using cocos2d. Cocos2d sits on top of OpenGL, of course, and I've found that this code doesn't affect FPS even for relatively complicated games.

You'll have to modify this a bit to work with your application, changing out the cocos2d calls, etc, but this will give you asynchronous loading of iAds, which should help the FPS issue.

To use this class, include its header and call

[[AdManager sharedManager] attachAdToView:self.view];

wherever you need iAds. The ads will remain hidden until an ad loads, at which time they'll pop up at the top of screen. (The class works for iOS 4.0, 4.1 and 4.2).

Also, I should add that I have cocos2d running inside of an overall UIViewController that I call "Cocos2DController". When I attach the ads to a cocos2d view, I'm using

[[AdManager sharedManager] attachAdToView:[[CCDirector sharedDirector] openGLView]];

Best of luck!

烟花易冷人易散 2024-10-10 11:34:52

我们可能会对苹果的选择感到失望,但要追求确定的事情,并在其他地方实施广告,以吸引人而不是侵入性的。这对于帧率和您来说都会更好。

We can hit and miss with apple's choices, but go for the sure thing and implement the ads in other parts to be appealing and not intrusive. It will be better for the framerate, and for you.

马蹄踏│碎落叶 2024-10-10 11:34:52

尝试在单独的低优先级线程中下载广告。因此,您可以确保广告加载不会占用太多 CPU 时间。通过一些 CPU 同步,您可以确保在新广告完全准备好显示之前不会尝试显示它。当然,它会从你想做的事情中占用一些 CPU 时间,但正确设置你的优先级,它应该只会在你忙着什么都不做时占用时间。

Try downloading the ads in a seperate, low priority, thread. You can, thus, nsure that the ads loading does not take too much CPU time. With a bit of CPU synchronisation you can make sure you don't try to display the new ad until it is completely ready to display. Sure it will suck some CPU time away from what you are trying to do but set your priorities right and it should only suck time when you are busy doing nothing.

你的他你的她 2024-10-10 11:34:52

请原谅这里的线程坏死,但我经常使用 Stack Overflow 来帮助我解决编码过程中遇到的问题,并且认为我的经验可能对将来的某人有用。

我的简单 cocos2d 游戏以不错的 FPS 运行(很少改变 FPS 显示),直到我实现 AdWhirl(仅集成 AdMob + iAd)。然后,在前几次迭代中,它会运行正常,但在第 9 次或第 10 次场景刷新时(单屏游戏,每个场景的平均时间小于 5 秒),FPS 将下降到约 20FPS,并且每次刷新时都会再次下降。场景焕然一新。

事实证明,在我的n00biness(这可能对我来说是特别的:))中,我是从内部调用场景的。也就是说,一旦操作完成,最后一个操作是再次调用主场景(一种重建场景的懒惰方式,以便用户再次进行操作)。这会重新初始化我插入的用于处理 AdWhirl 广告的视图和视图控制器,不仅出现内存泄漏,而且我还有 10 多个视图控制器都试图从 AdWhirl 请求广告并为其提供服务。一旦我找到了线索并去掉了自我引用循环,一切都很好。

Please excuse the thread necro'ing here, but I've used Stack Overflow a lot to help me through the problems I've had during coding, and thought my experience might be useful to someone in the future.

My simple cocos2d game ran with decent FPS (rarely changed the FPS display at all) until I implemented AdWhirl (integrating AdMob + iAd only). It would then run OK for the first few iterations, but upon upon the 9th or 10th scene refresh (single screen game, time in each scene < 5 seconds on average) the FPS would dive to ~20FPS, and drop again each time the scene refreshed.

Turns out, in my n00biness (this may be particular to me :) ), I was calling the scene from within itself. That is, once the actions had finished, the last action was to call the main scene again (a lazy way of rebuilding the scene for the user to have another go). This init'd the views and view controllers I had inserted to handle the AdWhirl ads all over again, and not only did I have a memory leak, I had 10+ view controllers all trying to request and service ads from AdWhirl. Once I got a clue and took that self-referring loop out, all was good.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文