控件不会进入我的xna代码中的update()和Draw()方法。 [英] Control is not going into the update() and Draw() methods in my xna code.
问题描述
我写了一个代码来更新XNA中某个骨骼的位置。
Mycode由三部分组成
第一部分是Loadcontent()
I wrote a code to update the position of one of the bones in XNA.
Mycode consists of three parts
First part is Loadcontent()
firstmodel = Content.Load<Model>("Models\\second-sample-");
worldtransforms = new Matrix[firstmodel.Bones.Count];
originalbonetransforms = new Matrix[firstmodel.Bones.Count];
bonetransforms = new Matrix[firstmodel.Bones.Count];
firstmodel.CopyAbsoluteBoneTransformsTo(originalbonetransforms);
firstmodel.CopyAbsoluteBoneTransformsTo(bonetransforms);
aspectratio = graphics.GraphicsDevice.Viewport.AspectRatio;
第二部分包括更新骨骼位置和更新worldtransform。
更新。
Second part consists of just updating the position of the bone and updating in worldtransform.
Update.
bonetransforms[Index] = originalbonetransforms[Index]* Matrix.CreateRotationX(50.5f) ;
worldtransforms[0] = bonetransforms[0];
for (int bone = 1; bone < worldtransforms.Length; bone++)
{
int parentbone = firstmodel.Bones[bone].Parent.Index;
worldtransforms[bone] = bonetransforms[bone] * worldtransforms[parentbone];
}
,最后Draw()方法和往常一样。
但控制直接进入
and finally Draw() method is as usual.
But control is directly going to
protected override void Initialize()
{
base.Initialize();
}
我将所有方法都定义为受保护。
我的问题是,只要我运行代码控制从Lodecontent()移动到Initialize(),模型显示在屏幕上,为什么它没有移动到Update()
I defined all my methods as protected.
My question is that as soon as i run the code control moves from Lodecontent() to Initialize() and the model is displayed on screen, why it is not moving in to Update()
推荐答案
我认为你有提出了一个好的有效问题。但无论如何,对于这种思维错误,我总是首先尝试阅读文档(如果我使用特定技术(API),则更多)。
请查看 http://msdn.microsoft.com/ en-us / library / microsoft.xna.framework.game.update.aspx [ ^ ]
另请阅读有关Initialize和Draw的信息 - 我认为这很好在那里解释 - 以及调用方法的顺序(或间隔)(简而言之:不要指望在初始化阶段调用更新的beeing)。
I think you have formulated a good and valid question. But anyway, for this kind of "mind bugs" I'd always try to read the docu first (even more if I use a specific technology (API)).
so have a look at http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.update.aspx[^]
Read also about Initialize and Draw - I think it's well explained there - and the sequence (or interval) the methods get called (in short: don't count on Updated beeing called during initialization phase).
这篇关于控件不会进入我的xna代码中的update()和Draw()方法。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!