帮助做循环冻结我的游戏! [英] help do loops freeze my game!

查看:74
本文介绍了帮助做循环冻结我的游戏!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的游戏第一次使用do and while循环,当一次到达时会立即冻结游戏,这是为什么?如果要做的是一个简单的函数

My game uses for first time the do and while loops and when reach one freezes the game instantaneusly why? If what to do is a simple function

推荐答案

如果您的循环位于主UI线程中并且无法快速退出,您将看到此行为.

You will see this behavior if your loop is in the main UI thread and it does not exit quickly.

避免设计代码,以免它陷入故意的延迟循环,从而浪费CPU时间和电池.使用计时器函数或辅助线程进行延迟,等待资源等.

Avoid designing your code so it spins in an intentional delay loop, which consumes CPU time as well as the battery. Use timer functions or secondary threads for delays, waiting on resources, etc.

如果您的代码示例无济于事,请发布.

Post your code sample if this does not help get you going.

希望这会有所帮助,
标记

Hope this helps,
Mark


这篇关于帮助做循环冻结我的游戏!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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