日期:2014-05-17 浏览次数:21005 次
public void GO(string key)
{
if (!this.AlloweKeys.Contains(key) || key == KeyEnum.K.ToString())
{
return;
}
//记录精灵位置
this.Direction = key;
//改变精灵方向
this.Directions(key);
double to = 0;
Storyboard storyboard = new Storyboard();
if (key == KeyEnum.A.ToString() || key == KeyEnum.D.ToString())
{
to = GetMove(key);
//设置左右移动多少
DoubleAnimation xAnimation = new DoubleAnimation()
{
To = to,
Duration = new Duration(TimeSpan.FromMilliseconds(this.DoTime))
};
Storyboard.SetTarget(xAnimation, this);
Storyboard.SetTargetProperty(xAnimation, new PropertyPath("(Canvas.Left)"));
storyboard.Children.Add(xAnimation);
}
if (key == KeyEnum.S.ToString() || key == KeyEnum.W.ToString())
{
to = GetMove(key);
//设置上下移动多少
DoubleAnimation yAnimation = new DoubleAnimation()
{
&