public void SuccessShortAnimationWithJump(Person player) { double dxPerFrame; float floatdxPerFrame; //每一帧在x方向上的移动,每一帧在y方向上的移动 dxPerFrame = (double)(player.dx * player.MoveDirection / shortAnimationFrames); floatdxPerFrame = player.dx * player.MoveDirection / shortAnimationFrames; //当短动画帧计数器小于给定的短动画帧数,绘画,当计数器等于给定的短动画帧数,结束动画,游戏逻辑进入下一状态 if (shortAnimationFrameCounts < shortAnimationFrames) { double x = player.Position[0] + dxPerFrame * (shortAnimationFrameCounts + 1); float fx = player.Position[0] + floatdxPerFrame * (shortAnimationFrameCounts + 1); double y = (double)player.XYofJump(fx); UCplayer.SetValue(Canvas.LeftProperty, x); UCplayer.SetValue(Canvas.BottomProperty, y); //翻跟头 Overturned(shortAnimationFrameCounts, shortAnimationFrames); shortAnimationFrameCounts++; if (shortAnimationFrameCounts == shortAnimationFrames)//这个的意思是当执行完stateindex=30的动画后,才执行索引 { shortAnimationFrameCounts = 0; RunDrawState130EndFlag = true; // drawStateIndex = 10; } } }
public void FailLongAnimationWithJump(Person player) { double dxPerFrame; float floatdxPerFrame; //每一帧在x方向上的移动,每一帧在y方向上的移动 dxPerFrame = (double)(player.dx * player.MoveDirection / longAnimationFrames); floatdxPerFrame = player.dx * player.MoveDirection / longAnimationFrames; if (longAnimationFrameCounts < longAnimationFrames) { //在跳跃工过程中,每一帧的x坐标,这是个绝对坐标中的坐标值,两个是一样的值,一个是double,一个是float,float是要带入一元二次方程的 double x = player.Position[0] + dxPerFrame * (longAnimationFrameCounts + 1); float fx = player.Position[0] + floatdxPerFrame * (longAnimationFrameCounts + 1); //在跳跃工过程中,每一帧的y坐标,这是个绝对坐标中的坐标值,把x坐标带入一元二次方程中得出的y double y = (double)player.XYofJump(fx); UCplayer.SetValue(Canvas.LeftProperty, x); UCplayer.SetValue(Canvas.BottomProperty, y); //翻跟头 Overturned(longAnimationFrameCounts, longAnimationFrames); longAnimationFrameCounts++; if (longAnimationFrameCounts == longAnimationFrames) { longAnimationFrameCounts = 0; RunDrawState133EndFlag = true; } } }
public void SuccessLongAnimationWithJump(Person player) { double dxPerFrame; float floatdxPerFrame; //每一帧在x方向上的移动的相对位移,相对值,有正负,正为跳跃方向为1,x坐标增加,负为跳跃方向为-1,x坐标减少 dxPerFrame = (double)(player.dx * player.MoveDirection / longAnimationFrames); //用来计算跳跃时每一帧在x方向上的相对位移,相对值,值与上一个一样,不过采用float型表示,用来带入方程 floatdxPerFrame = player.dx * player.MoveDirection / longAnimationFrames;; if (longAnimationFrameCounts < longAnimationFrames) { //在跳跃工过程中,每一帧的x坐标,这是个绝对坐标中的坐标值,两个是一样的值,一个是double,一个是float,float是要带入一元二次方程的 double x = player.Position[0] + dxPerFrame * (longAnimationFrameCounts + 1); float fx = player.Position[0] + floatdxPerFrame * (longAnimationFrameCounts + 1); //在跳跃工过程中,每一帧的y坐标,这是个绝对坐标中的坐标值,把x坐标带入一元二次方程中得出的y double y = (double)player.XYofJump(fx); UCplayer.SetValue(Canvas.LeftProperty, x);//这里设置canvas的值是double型的,x是double型的 UCplayer.SetValue(Canvas.BottomProperty, y); //翻跟头 Overturned(longAnimationFrameCounts, longAnimationFrames); longAnimationFrameCounts++; if (longAnimationFrameCounts == longAnimationFrames) { longAnimationFrameCounts = 0; RunDrawState132EndFlag = true; } } }
public void FailLongAnimation(Person player) { double dxPerFrame, dyPerFrame; //每一帧在x方向上的移动,每一帧在y方向上的移动 dxPerFrame = (double)(player.dx * player.MoveDirection / longAnimationFrames); dyPerFrame = (double)(player.dy / longAnimationFrames); if (longAnimationFrameCounts < longAnimationFrames) { UCplayer.SetValue(Canvas.LeftProperty, player.Position[0] + dxPerFrame * (longAnimationFrameCounts + 1)); UCplayer.SetValue(Canvas.BottomProperty, player.Position[1] + dyPerFrame * (longAnimationFrameCounts + 1)); longAnimationFrameCounts++; if (longAnimationFrameCounts == longAnimationFrames) { longAnimationFrameCounts = 0; RunDrawState133EndFlag = true; } } }
//跳跃失败的动画,跳在了两方块之间 public void FailShortAnimation(Person player) { double dxPerFrame, dyPerFrame; //每一帧在x方向上的移动,每一帧在y方向上的移动 dxPerFrame = (double)(player.dx * player.MoveDirection / shortAnimationFrames); dyPerFrame = (double)(player.dy / shortAnimationFrames); //当短动画帧计数器小于给定的短动画帧数,绘画,当计数器等于给定的短动画帧数,结束动画,游戏逻辑进入下一状态 if (shortAnimationFrameCounts < shortAnimationFrames) { UCplayer.SetValue(Canvas.LeftProperty, player.Position[0] + dxPerFrame * (shortAnimationFrameCounts + 1)); UCplayer.SetValue(Canvas.BottomProperty, player.Position[1] + dyPerFrame * (shortAnimationFrameCounts + 1)); shortAnimationFrameCounts++; if (shortAnimationFrameCounts == shortAnimationFrames) { shortAnimationFrameCounts = 0; RunDrawState131EndFlag = true; } } }