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

查看:105
本文介绍了看似随机的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 设置为。上述物理体不会相互碰撞,但它们会与播放器节点发生冲突。播放器节点没有快速移动,并且通常一次仅触摸大约5个节点。当玩家节点与其他一些物理机构联系时,他们的动态属性设置为 YES
也许值得一提的是,我有几个 UIView s和 UIImageView s覆盖了作为HUD的 SKView 的顶部。

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.

这让我觉得这不是一个特别密集的模拟。我已经完成了我的 - 更新:方法,操作,联系人监听器等,但没有发现可能导致此问题的任何内容。我花了最近几天在仪器(Time Profiler),希望它可以解决这个问题,但同样,我没有发现任何跳出来的东西。但是,我承认对仪器很新。

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天全站免登陆