Xna快速提问!!! [英] Xna Quick question!!!

查看:68
本文介绍了Xna快速提问!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅,我有这段代码 -

See,I have this code-

if (RunsCollision.isrunnew == true)
           { i = 0;
           do
           {

               i += 0.1f;
               Game1.spriteBatch.Begin();
               Game1.spriteBatch.DrawString(Game1.scorefont, runstoshow, new Vector2(200, 200), color);
               Game1.spriteBatch.End();
           } while (i < 100);
           }
           RunsCollision.isrunnew = false;





当我在Draw()方法中运行此代码时,文本只显示约1秒钟。我想要文本要显示5秒。我试过更改值但仍然没有运气。

请帮助我完成我的学校项目。紧急。



when I run this code in my Draw() method,the text appears for only about 1 second.I want the text to be displayed for 5 seconds.I have tried changing the values but still no luck.
Please help me fir my school project.Its urgent.

推荐答案

我知道这已经很晚了,但是如果有人读到这个,或者你还没有想出来的话;你不应该在绘图程序中处理计时器。你基本上试图用你的while循环在这里睡觉。更合适的是使用Update()方法,它允许您访问gameTime并检查gameTime.ellapsedGameTime.totalmilliseconds。在Update()方法中你也将检查冲突,如果你需要在碰撞后开始像这个SpriteFont这样的定时,你应该有一个绘制例程有权访问的bool,你将在Update中标记true / false( )当你想要绘制SpriteFont时。
I know this is very late, but in case anyone reads this, or if you haven't figured it out yet; you should not be handling the timer in your draw routine. You're basically trying to sleep the thread here with your while loop. What would be more appropriate is using the Update() method which gives you access to the gameTime and check for gameTime.ellapsedGameTime.totalmilliseconds. In the Update() method you will also be checking collisions, if you need to start timing something like this SpriteFont after a collision, you should have a bool that draw routine has access to that you will mark true/false from within the Update() method when you want the SpriteFont to be drawn.


这篇关于Xna快速提问!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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