C# 如何在XNA上停止模型动画?
我不明白如何暂停XNA的动画。我可以启动模型的动画,但不能停止它。 我使用SkinningSample\u 4\u 0示例dll 这是我要使用的代码C# 如何在XNA上停止模型动画?,c#,animation,model,xna,C#,Animation,Model,Xna,我不明白如何暂停XNA的动画。我可以启动模型的动画,但不能停止它。 我使用SkinningSample\u 4\u 0示例dll 这是我要使用的代码 protected override void LoadContent() { //Model - Player model_player = Content.Load<Model>("Models\\Player\\models"); //
protected override void LoadContent()
{
//Model - Player
model_player = Content.Load<Model>("Models\\Player\\models");
// Look up our custom skinning information.
SkinningData skinningData = model_player.Tag as SkinningData;
if (skinningData == null)
throw new InvalidOperationException
("This model does not contain a SkinningData tag.");
// Create an animation player, and start decoding an animation clip.
animationPlayer = new AnimationPlayer(skinningData);
AnimationClip clip = skinningData.AnimationClips["ArmLowAction_006"];
animationPlayer.StartClip(clip);
}
protected overide update(GameTime gameTime)
{
KeyboardState key = Keyboard.GetState();
animationPlayer.Update(gameTime.ElapsedGameTime, true, Matrix.Identity);
// If player don't move -> stop anim
if (!key.IsKeyDown(Keys.W) && !keyStateOld.IsKeyUp(Keys.S) && !keyStateOld.IsKeyUp(Keys.A) && !keyStateOld.IsKeyUp(Keys.D))
{
//animation stop ? not exist ?
animationPlayer.Stop();
isPlayerStop = true;
}
else
{
if(isPlayerStop == true)
{
isPlayerStop = false;
animationPlayer.StartClip(Clip);
}
}
我终于自己找到了^^
if (!key.IsKeyDown(Keys.W) && !key.IsKeyDown(Keys.A) && !key.IsKeyDown(Keys.D) && !key.IsKeyDown(Keys.S))
{
//Stop animation for player walking
animationPlayer.Update(new TimeSpan(0, 0, 0), true, Matrix.Identity);
}
else
{
//Continue the animation
animationPlayer.Update(gameTime.ElapsedGameTime, true, Matrix.Identity);
}
对不起,我会手动得到回复。对不起,这个问题真的不清楚。对不起,我编辑了我问题的解释。我试着把它缩短,效果更好。因为我不会说基础英语。