C#制作动画...... [英] C# making an animation...............

查看:189
本文介绍了C#制作动画......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码

 私有  void  timer2_Tick(对象发​​件人,EventArgs e)
       {
            // 级别1 
            int 运动=  0 ;
           如果(label2.Text == " )
           {movement =  5 ;
               如果(Death.Width ==  64 )
               {
                   Death.Location =  Point(Death.Location.X +动作,Death.Location.Y);
               }

               如果(死亡位置== 点( 390  202 ))
               {
                   Death.Width =  63 ;
               }
               如果(Death.Width ==  63 )
               {
                   Death.Location =  Point(Death.Location.X-运动,Death.Location.Y);
               }

               如果(死亡位置== 点( 30  202 ))
               {
                   Death.Width =  64 ;
               }
           }
           //  2级
           如果(label2.Text == " )
           {movement =  15 ;
               如果(Death.Width ==  64 )
               {
                   Death.Location =  Point(Death.Location.X +动作,Death.Location.Y);
               }

               如果(死亡位置== 点( 390  202 ))
               {
                   Death.Width =  63 ;
               }
               如果(Death.Width ==  63 )
               {
                   Death.Location =  Point(Death.Location.X-运动,Death.Location.Y);
               }

               如果(死亡位置== 点( 30  202 ))
               {
                   Death.Width =  64 ;
               }
           }

       } 



当它达到2级时,它的运行速度甚至会提高,但由于某种原因它会冻结,有人可以帮助我吗?对我来说没问题.因为我不知道死亡"是什么,所以我将按钮命名为死亡",并且在移动时可以清楚地看到两种速度.因此,您的代码的另一部分必定有问题.


This is my code

private void timer2_Tick(object sender, EventArgs e)
       {
            // level 1
           int movement = 0;
           if (label2.Text == "This Is Level 1")
           {movement = 5;
               if (Death.Width == 64)
               {
                   Death.Location = new Point(Death.Location.X + movement, Death.Location.Y);
               }

               if (Death.Location == new Point(390, 202))
               {
                   Death.Width = 63;
               }
               if (Death.Width == 63)
               {
                   Death.Location = new Point(Death.Location.X - movement, Death.Location.Y);
               }

               if (Death.Location == new Point(30, 202))
               {
                   Death.Width = 64;
               }
           }
           // level 2
           if (label2.Text == "This Is Level 2")
           {movement = 15;
               if (Death.Width == 64)
               {
                   Death.Location = new Point(Death.Location.X + movement, Death.Location.Y);
               }

               if (Death.Location == new Point(390, 202))
               {
                   Death.Width = 63;
               }
               if (Death.Width == 63)
               {
                   Death.Location = new Point(Death.Location.X - movement, Death.Location.Y);
               }

               if (Death.Location == new Point(30, 202))
               {
                   Death.Width = 64;
               }
           }

       }



When it hits level 2 its meant to go even faster but for some reason it just freezes, can anyone help me?

解决方案

I just tried your code and it is working fine for me. As I don''t know what "Death" is, I named a button as Death and I can clearly see the two speeds when moving. So, there must be some issue in another part of your code.


这篇关于C#制作动画......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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