⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 animationnpc.java

📁 J2ME游戏引擎,直接在JBUILDER2006下运行,不包含需要的SDK和虚拟机
💻 JAVA
字号:
//package GoGoGo;
//
//public class AnimationNPC
//{
//    //方向状态
//    public int  Left_run=0;
//    public int  right_run=1;
//    public int  up_run=2;
//    public int  down_run=3;
//    public int  Left_stand=4;
//    public int  right_stand=5;
//    public int  up_stand=6;
//    public int  down_stand=7;
//    //攻击动画播放状态
//    public int  ACT=8;
//   //当前播放帧数
//   public int Action_run_left = 0;
//   public int Action_run_right = 0;
//   public int Action_run_up = 0;
//   public int Action_run_down = 0;
//   public int Action_stand_left = 0;
//   public int Action_stand_right = 0;
//   public int Action_stand_up = 0;
//   public int Action_stand_down = 0;
//   public int Action_ACT_left = 0;
//   public int Action_ACT_right = 0;
//   public int Action_ACT_up = 0;
//   public int Action_ACT_down = 0;
//
//   //攻击前的状态
//   public int  Current_station=-1;
//  //帧播放初始位置
//  int Station_start []={0,0,0,0,0,2,6,6,0,0,0,0};//左右上下(跑),左右上下(站立)
//  //帧播放结束位置
//  int Station_end []={5,5,5,5,0,2,6,6,4,4,4,4};//左右上下(跑),左右上下(站立)
//  //帧间距
//  int distance_W[]={26,26,34,34,26,26,34,34,75,75,75,75};//左右上下(跑),左右上下(站立)
//  //帧高度
//  int distance_H[]={38,38,42,42,38,38,42,42,54,54,54,54};//左右上下(跑),左右上下(站立)
//  //动画最大数量
//  int animation_number=12;
//    public AnimationNPC()
//    {
//     init_animation();
//    }
////初始化帧位置
//    public void init_animation()
//    {
//        for (int i = 0; i < animation_number; i++)
//        {
//            switch (i)
//            {
//                case 0: //向左跑动
//                    Action_run_left = Station_start[i];
//                    break;
//                case 1: //向右跑动
//                    Action_run_right = Station_start[i];
//                    break;
//                case 2:
//                    Action_run_up = Station_start[i];
//                    break;
//                case 3:
//                     Action_run_down = Station_start[i];
//                    break;
//                case 4:
//                    Action_stand_left =Station_start[i];
//                    break;
//                case 5:
//                    Action_stand_right = Station_start[i];
//                    break;
//                case 6:
//                    Action_stand_up = Station_start[i];
//                    break;
//                case 7:
//                    Action_stand_down = Station_start[i];
//                    break;
//                case 8:
//                    Action_ACT_left = Station_start[i];
//                    break;
//                case 9:
//                    Action_ACT_right = Station_start[i];
//                    break;
//                case 10:
//                    Action_ACT_up = Station_start[i];
//                    break;
//                case 11:
//                    Action_ACT_down = Station_start[i];
//                    break;
//            }
//
//        }
//    }
//
//    //动画播放控制 返回需要绘制的原图位置
//   /* public int Animation_run(int animation)
//    {
//        int Distance = 0;
//        switch (animation)
//        {
//            case 0: //向左跑动
//                Action_run_left++;
//                if (Action_run_left > Station_end[animation])
//                {
//                    Action_run_left = Station_start[animation];
//                }
//                Distance = Action_run_left;
//                break;
//            case 1: //向右跑动
//                Action_run_right++;
//                if (Action_run_right > Station_end[animation])
//                {
//                    Action_run_right = Station_start[animation];
//                }
//                Distance = Action_run_right;
//                break;
//            case 2:
//                Action_run_up++;
//                if (Action_run_up > Station_end[animation])
//                {
//                    Action_run_up = Station_start[animation];
//                }
//                Distance = Action_run_up;
//
//                break;
//            case 3:
//                Action_run_down++;
//                if (Action_run_down > Station_end[animation])
//                {
//                    Action_run_down = Station_start[animation];
//                }
//                Distance = Action_run_down;
//
//                break;
//            case 4:
//                Action_stand_left++;
//                if (Action_stand_left > Station_end[animation])
//                {
//                    Action_stand_left = Station_start[animation];
//                }
//                Distance = Action_stand_left;
//                break;
//            case 5:
//                Action_stand_right++;
//                if (Action_stand_right > Station_end[animation])
//                {
//                    Action_stand_right = Station_start[animation];
//                }
//                Distance = Action_stand_right;
//
//                break;
//            case 6:
//                Action_stand_up++;
//                if (Action_stand_up > Station_end[animation])
//                {
//                    Action_stand_up = Station_start[animation];
//                }
//                Distance = Action_stand_up;
//                break;
//            case 7:
//                Action_stand_down++;
//                if (Action_stand_down > Station_end[animation])
//                {
//                    Action_stand_down = Station_start[animation];
//                }
//                Distance = Action_stand_down;
//                break;
//        }
//        return Distance * distance_W[animation];
//    }*/
//    public int Animation_ACT(int animation)//攻击动画状态控制
//    {
//        int Distance = 0;
//        switch (animation)
//        {
//            case 0: //向左
//            case 4:
//                Action_ACT_left++;
//                if (Action_ACT_left > Station_end[8])
//                {
//                    Action_ACT_left = Station_start[8];
//                }
//                Distance = Action_ACT_left;
//                break;
//            case 1: //向右
//            case 5:
//                Action_ACT_right++;
//                if (Action_ACT_right > Station_end[9])
//                {
//                    Action_ACT_right = Station_start[9];
//                }
//                Distance = Action_ACT_right;
//                break;
//            case 2://向上
//            case 6:
//                Action_ACT_up++;
//                if (Action_ACT_up > Station_end[10])
//                {
//                    Action_ACT_up = Station_start[10];
//                }
//                Distance = Action_ACT_up;
//
//                break;
//            case 3://向下
//            case 7:
//                Action_ACT_down++;
//                if (Action_ACT_down > Station_end[11])
//                {
//                    Action_ACT_down = Station_start[11];
//                }
//                Distance = Action_ACT_down;
//                break;
//        }
//        if(animation <4)
//        return Distance * distance_W[animation+8];
//        else
//        return Distance * distance_W[animation+4];
//    }
//
//    //原图每帧宽
//    public int getwidth(int animation)
//    {
//        return   distance_W[animation];
//    }
//    //原图每帧高
//    public int getheight(int animation)
//    {
//        return   distance_H[animation];
//    }
//
//}
//

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -