SpriteKit,看似随机,降至 40 FPS [英] SpriteKit, Seemingly at Random, Drops To 40 FPS

查看:29
本文介绍了SpriteKit,看似随机,降至 40 FPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SpriteKit 编写一个 iOS 游戏.在游戏过程中,显然是随机的,帧速率将从 60 FPS 下降到 40 FPS(始终为 40).我在 iPhone 6 上运行它.在构建发布和调试时存在该错误.

I'm writing an iOS game, using SpriteKit. At, apparently random, times during gameplay, the frame-rate will drop from 60 FPS to 40 FPS (always 40). I'm running this on an iPhone 6. The bug is present when building for release and debug.

我通常一次在屏幕上大约有 30 个节点(有时更少),其中大多数节点都有物理体,但是,除了大约 5 个之外,所有节点都将 dynamic 设置为 NO.前面提到的物理体不会相互碰撞,但是它们会与玩家节点发生碰撞.玩家节点移动速度不快,通常一次只接触大约 5 个左右的节点.当玩家节点与其他一些物理体接触时,它们的 dynamic 属性设置为 YES.值得一提的是,我有几个 UIViewUIImageView 覆盖在 SKView 的顶部,充当 HUD.

I typically have around 30 nodes on screen at a time (sometimes less), most of those nodes have physics bodies, however, all but around 5 have dynamic set to NO. The aforementioned physics bodies do not collide with each other, however they do collide with the player node. The player node is not moving quickly, and usually is only touching around 5 or so nodes at a time. When the player node comes into contact with some of the other physics bodies, their dynamic property is set to YES. It might also be worth mentioning, that I have a couple of UIViews and UIImageViews overlaying the top of the SKView, acting as the HUD.

令我震惊的是,这不是一个特别密集的模拟.我已经检查了我的 - update: 方法、操作、联系侦听器等,但没有发现任何可能导致这种情况的东西.我在 Instruments (Time Profiler) 中度过了最后几天,希望它能对此事有所启发,但同样,我还没有发现任何让我大吃一惊的东西.但是,我承认我对 Instruments 还很陌生.

It strikes me that this is not a particularly intensive simulation. I have gone through my - update: methods, actions, contact listeners, etc. and not found anything that might be causing this. I've spent the last few days in Instruments (Time Profiler), hoping it might shed some light on the matter, but again, I've not found anything that jumps out at me. However, I'll admit to being quite new to Instruments.

目前,我无法重现该错误.我只需要玩游戏,希望能遇到它.有时它会在场景加载时发生(非常罕见),只是在正常游戏过程中,或者根本不发生.如果我暂停游戏(暂停视图和场景)并恢复它,帧速率就会恢复.有时帧率会在几秒钟后恢复正常.我完全不知道在这里做什么.任何帮助将不胜感激.

Right now, I have no way of reproducing the bug. I just have to play the game, and hope to encounter it. Sometimes it will happen when the scene loads in (quite rare), just during normal gameplay, or not at all. If I pause the game (pause the view and scene), and resume it, the frame-rate goes back up. Sometimes the frame-rate will return to normal after several seconds. I'm completely at a loss of what to do here. Any help would be much appreciated.

提前致谢.

推荐答案

我能想到的唯一一件事是,如果你的 HUD 的所有纹理还没有预渲染,为什么会出现大幅帧率下降.因此,您可能已经预渲染了初始 HUD 和一些其他图像,但 HUD 在游戏中触发某些事件时使用了一些图像.

The only thing I can think of for why you would have a massive frame rate drop is if all the textures for your HUD is not already pre-rendered. So you might have the initial HUD pre-rendered and some other images but some images the HUD uses when some event is triggered in game.

这篇关于SpriteKit,看似随机,降至 40 FPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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