iOS游戏开发中还有其他播放背景音乐的方式吗?

发布于 2024-12-09 04:12:43 字数 185 浏览 0 评论 0原文

我现在有一个问题。我使用 cocos2d 开发 iPad 游戏应用程序。在我的应用程序中,我使用背景音乐。当我使用cocos2d音乐方法SimpleAudioEngine时,我遇到了泄漏。然而,我的老板不希望我们的应用程序出现泄漏。除了使用 SimpleAudioEngine 之外还有其他方式播放背景音乐并且不会泄漏吗?

谢谢之前。问候。

I have a problem right now. I develop game application for iPad with cocos2d. In my application, I use background music. When I use cocos2d music method SimpleAudioEngine, i got leak. However, my bos don't want have a leak in our application. Any other way to play background music except using SimpleAudioEngine and not get a leak?

Thanx before. Regards.

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

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

发布评论

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

评论(2

原来分手还会想你 2024-12-16 04:12:43

你怎么知道你有泄漏?很多时候,被报告为泄漏的情况实际上并不是泄漏,也不是您自己的代码中的泄漏。特别是静态分析器仅提出建议,但他的假设常常是错误的。

您可能还想联系库作者 Steve Oldmeadow,可以在 cocos2d 论坛上找到他。至少他可以确认一个错误,或者解释为什么这不是泄漏。

其次,我不会太重视泄漏问题。假设您每次开始播放音乐时都会泄漏 16 字节。您必须启动音乐 16,000 次才能泄漏 16 KB。在您的应用程序中出现这种情况的可能性有多大?您“需要”这 16 KB 的程度如何?

第三,告诉你的老板你修复了漏洞。如果他不希望应用程序出现泄漏,那么他显然不是一个(好的)程序员。我知道这是一个谎言,而且我知道会有程序员讨厌我。但实际上,在你花费数小时甚至数天寻找一种“更好”的音乐播放方式(可能还有其他副作用)而不是使用数百个 iPhone 应用程序中经过验证的方法之前,这样的善意谎言将拯救你的老板一堆钱。

我认为太多人认为内存泄漏等于应用程序经常崩溃。情况并非如此,除非泄漏很严重,导致内存不足错误或在某些情况下出现内存碎片。

How do you know that you have a leak? Often times what is reported as a leak truly isn't a leak, or a leak in your own code. In particular the static analyzer only makes suggestions but is quite often wrong about his assumptions.

You may also want to contact the library author Steve Oldmeadow, he can be found on the cocos2d forum. At least he may be able to confirm a bug, or explain why it's not a leak.

Secondly, I wouldn't put too much weight on the leaks. Let's assume you're leaking 16 Bytes every time you start a music. You would have to start the music 16.000 times to have leaked 16 KB. How likely is this in your app, and how badly do you "need" those 16 KB?

Third, tell your boss you fixed the leak. If he doesn't want leaks in the app, he's obviously not a (good) programmer. I know it's a lie, and I know there's going to be programmers who'll hate me. But really before you spend hours or even days to find a "better" way of playing music (possibly with other side effects) rather than using what's tried and true in hundreds of iPhone apps, such a white lie is going to save your boss a bunch of money.

I think that too many people think that leaking memory equals an app that crashes often. Such is not the case, unless the leaks are significant, resulting in out of memory errors or in some scenarios memory fragmentation.

不如归去 2024-12-16 04:12:43

您可以使用 SoundMaster 引擎代替 CocosDension 声音引擎ARC 支持、内存管理(无泄漏) 以及许多其他功能,例如淡入/淡出相对卷效果或交叉淡入淡出

You can use SoundMaster engine instead of CocosDension Sound Engine. ARC support, memory management (NO LEAKS) and many other features like fade in/out, relative volumes for effects or cross-fades.

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