Example #1
0
        //cube出现后的下落反弹动画。本来应该在RunDraw里,但是写在里面会出现一些时间上的问题。

        /*跳一跳原版里,当小人成功跳到cube的一瞬间,出现下一cube,此时cube在高处,经过几帧的动画后,下一个cube下落反弹最终触地,与此同时,镜头开始移动,最终在下一cube稳定落地时镜头也移动结束。
         * 但是,当小人当小人成功跳到cube的一瞬间,就可以开始蓄力下一次跳跃了。也就是说在此时下一个cube还没落地,镜头也没完全移动结束,但是就可以开始蓄力了。为了实现这个机制,不得不把cube下落反
         * 弹动画独立出来,暂时想到的是这个方法,以后再优化*/
        public void RunCubeFall()
        {
            switch (cubeFallIndex)
            {
            case 0:
            {
                break;
            }

            case 1:
            {
                if (CreatNewCubeFrameCounts < CreatNewCubeFrames)
                {
                    double x      = (1d / CreatNewCubeFrames) * (CreatNewCubeFrameCounts + 1);
                    double yvalue = 250 * BounceEaseOutFucntion(x);
                    //double y = (NowCube.Position[1] + NextCube.dy + 250 - (250d / CreatNewCubeFrames) * (CreatNewCubeFrameCounts + 1));//线性下落test
                    double y = (NowCube.Position[1] + NextCube.dy + (250 - yvalue));
                    UcNextCubeCom.SetValue(Canvas.BottomProperty, y);
                    CreatNewCubeFrameCounts++;
                }
                if (CreatNewCubeFrameCounts == CreatNewCubeFrames)
                {
                    CreatNewCubeFrameCounts = 0;
                    cubeFallIndex           = 0;
                }
                break;
            }
            }
        }
Example #2
0
        //跳跃成功后生成新cube,并改变镜头位置状态backgroundMoveIndex = 1,下个循环开始背景移动
        public void ShowNewCube()
        {
            //UcNowCubeCom = UCcubecom1;

            // UCcube1 UCcube0 = new UCcube1();
            UCcubeCompression UCcubecom1 = new UCcubeCompression();

            //Layer_Cube.Children.Add(UCcube0);
            //UCcube0.SetValue(Canvas.LeftProperty, (double)(NowCube.Position[0] + (NextCube.k * NextCube.dx)));
            //UCcube0.SetValue(Canvas.BottomProperty, (double)(NowCube.Position[1] + NextCube.dy));
            Layer_Cube.Children.Add(UCcubecom1);
            UCcubecom1.SetValue(Canvas.LeftProperty, (double)(NowCube.Position[0] + (NextCube.k * NextCube.dx)));
            UCcubecom1.SetValue(Canvas.BottomProperty, (double)(NowCube.Position[1] + NextCube.dy));

            //更新,现在的UcNowCubeCom是刚才的UcNextCubeCom,现在的UcNextCubeCom是新生成的UCcubecom1
            UcNowCubeCom        = UcNextCubeCom;
            UcNextCubeCom       = UCcubecom1;
            backgroundMoveIndex = 1;
        }