幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3328|回复: 2

[讨论] 跪拜求助 击打小人flash的代码测试没有反应

[复制链接]

1

主题

2

帖子

23

积分

②入门

积分
23
发表于 2009-12-17 18:12:53 | 显示全部楼层 |阅读模式
这是源代码,应该是在flash8里做的
stop();

VEL_SAL_LIMIT = 70;

VEL_HIT_LIMIT = 180;

DIVIDE_NUM_STRIKE = 30;

DIVIDE_NUM_HIT = 24;

DIVIDE_NUM_SAL = 12;
Area_Head_Left._visible = false;
Area_Head_Right._visible = false;
Area_Arm_Left._visible = false;
Area_Arm_Right._visible = false;
Area_Leg_Left._visible = false;
Area_Leg_Right._visible = false;
cursor_old_x = 0.0;
cursor_old_y = 0.0;
cursor_new_x = 0.0;
cursor_new_y = 0.0;
cursor_velocity = 0.0;
HitArea = "";
divide_num = 1;
xpoint_array = new Array();
ypoint_array = new Array();
init = false;

function CalVelocity() {
cursor_old_x = cursor_new_x;
cursor_old_y = cursor_new_y;
cursor_new_x = int(this._xmouse);
cursor_new_y = int(this._ymouse);
cursor_velocity = int(Math.sqrt(Math.pow(cursor_new_x-cursor_old_x, 2)+Math.pow(cursor_new_y-cursor_old_y, 2)));
}
function CalPoints() {
if (cursor_velocity>VEL_HIT_LIMIT) {
  divide_num = DIVIDE_NUM_STRIKE;
} else if (cursor_velocity>VEL_SAL_LIMIT) {
  divide_num = DIVIDE_NUM_HIT;
} else {
  divide_num = DIVIDE_NUM_SAL;
}
xdivide = (cursor_new_x-cursor_old_x)/divide_num;
ydivide = (cursor_new_y-cursor_old_y)/divide_num;
for (i=0; i<divide_num; i++) {
  xpoint_array = cursor_old_x+(xdivide*(i+1));
  ypoint_array = cursor_old_y+(ydivide*(i+1));
}
}

function HitCheck() {
for (i=0; i<divide_num; i++) {
  if (Area_Head_Left.hitTest(xpoint_array, ypoint_array, true)) {
   if (!Area_Head_Left.hitTest(cursor_old_x, cursor_old_y, true)) {
    if (xpoint_array>cursor_old_x) {
     HitArea = "Area_Head_Left";
     break;
    }
   }
  } else if (Area_Head_Right.hitTest(xpoint_array, ypoint_array, true)) {
   if (!Area_Head_Right.hitTest(cursor_old_x, cursor_old_y, true)) {
    if (xpoint_array<cursor_old_x) {
     HitArea = "Area_Head_Right";
     break;
    }
   }
  } else if (Area_Arm_Left.hitTest(xpoint_array, ypoint_array, true)) {
   if (!Area_Arm_Left.hitTest(cursor_old_x, cursor_old_y, true)) {
    if (xpoint_array>cursor_old_x) {
     HitArea = "Area_Arm_Left";
     break;
    }
   }
  } else if (Area_Arm_Right.hitTest(xpoint_array, ypoint_array, true)) {
   if (!Area_Arm_Right.hitTest(cursor_old_x, cursor_old_y, true)) {
    if (xpoint_array<cursor_old_x) {
     HitArea = "Area_Arm_Right";
     break;
    }
   }
  } else if (Area_Leg_Left.hitTest(xpoint_array, ypoint_array, true)) {
   if (!Area_Leg_Left.hitTest(cursor_old_x, cursor_old_y, true)) {
    if (xpoint_array>cursor_old_x) {
     HitArea = "Area_Leg_Left";
     break;
    }
   }
  } else if (Area_Leg_Right.hitTest(xpoint_array, ypoint_array, true)) {
   if (!Area_Leg_Right.hitTest(cursor_old_x, cursor_old_y, true)) {
    if (xpoint_array<cursor_old_x) {
     HitArea = "Area_Leg_Right";
     break;
    }
   }
  }
}
}

function StartMotion() {
_root.Motion_all.gotoAndPlay(togo);
}

onEnterFrame = function () {
CalVelocity();
CalPoints();
HitCheck();
if (!init) {
  HitArea = "";
  init = true;
}
switch (HitArea) {
case "Area_Head_Left" :
  if (divide_num == DIVIDE_NUM_SAL) {
   togo = "TL_w";
  } else if (divide_num == DIVIDE_NUM_HIT) {
   togo = "TL_m";
  } else if (divide_num == DIVIDE_NUM_STRIKE) {
   togo = "TL_s";
  }
  StartMotion();
  HitArea = "";
  break;
case "Area_Head_Right" :
  if (divide_num == DIVIDE_NUM_SAL) {
   togo = "TR_w";
  } else if (divide_num == DIVIDE_NUM_HIT) {
   togo = "TR_m";
  } else if (divide_num == DIVIDE_NUM_STRIKE) {
   togo = "TR_s";
  }
  StartMotion();
  HitArea = "";
  break;
case "Area_Arm_Left" :
  if (divide_num == DIVIDE_NUM_SAL) {
   togo = "ML_w";
  } else if (divide_num == DIVIDE_NUM_HIT) {
   togo = "ML_s";
  } else if (divide_num == DIVIDE_NUM_STRIKE) {
   togo = "ML_s";
  }
  StartMotion();
  HitArea = "";
  break;
case "Area_Arm_Right" :
  if (divide_num == DIVIDE_NUM_SAL) {
   togo = "MR_w";
  } else if (divide_num == DIVIDE_NUM_HIT) {
   togo = "MR_s";
  } else if (divide_num == DIVIDE_NUM_STRIKE) {
   togo = "MR_s";
  }
  StartMotion();
  HitArea = "";
  break;
case "Area_Leg_Left" :
  if (divide_num == DIVIDE_NUM_SAL) {
   togo = "BL_w";
  } else if (divide_num == DIVIDE_NUM_HIT) {
   togo = "B_m";
  } else if (divide_num == DIVIDE_NUM_STRIKE) {
   togo = "BL_s";
  }
  StartMotion();
  HitArea = "";
  break;
case "Area_Leg_Right" :
  if (divide_num == DIVIDE_NUM_SAL) {
   togo = "BR_w";
  } else if (divide_num == DIVIDE_NUM_HIT) {
   togo = "B_m";
  } else if (divide_num == DIVIDE_NUM_STRIKE) {
   togo = "BR_s";
  }
  StartMotion();
  HitArea = "";
  break;
}
};


下面是我用cs3的2.0做的,测试hitTest这步时没反应,求达人帮忙~

stop();
w_v = 70;
s_v = 180;
s_h = 30;
m_h = 24;
w_h = 12;
head_left._visible = false;
head_right._visible = false;
arm_left._visible = false;
arm_right._visible = false;
leg_left._visible = false;
leg_right._visible = false;
m_o_x = 0.0;
m_o_y = 0.0;
m_n_x = 0.0;
m_n_y = 0.0;
m_v = 0.0;
hit_eara = "";
fj = 1;
xpoint_array = new Array();
ypoint_array = new Array();
ini = false;
function jsms() {
m_o_x = m_n_x;
m_o_y = m_n_y;
m_n_x = int(this._xmouse);
m_n_y = int(this._ymouse);
m_v = int(Math.sqrt(Math.pow(m_n_x-m_o_x, 2)+Math.pow(m_n_y-m_o_y, 2)));
}
function poinv() {
if (m_v>s_v) {
  fj = s_h;
} else if (m_v>w_v) {
  fj = m_h;
} else {
  fj = w_h;
}
xfj = (m_n_x-m_o_x)/fj;
yfj = (m_n_y-m_o_y)/fj;
for (i=0; i<fj; i++) {
  xpoint_array = m_d_x+xfj*(i+1);
  ypoint_array = m_d_y+xfj*(i+1);
}
}
function hit() {
for (i=0; i<fj; i++) {
  if (head_left.hitTest(xpoint_array, ypoint_array, true)) {
   if (!head_left.hitTest(m_o_x, m_o_y, true)) {
    if (xpoint_array>m_o_x) {
     hit_eara = "head_left";
     break;
    }
   }
  } else if (arm_left.hitTest(xpoint_array, ypoint_array, true)) {
   if (!arm_left.hitTest(m_o_x, m_o_y, true)) {
    if (xpoint_array>m_o_x) {
     hit_eara = "arm_left";
     break;
    }
   }
  } else if (leg_left.hitTest(xpoint_array, ypoint_array, true)) {
   if (!leg_left.hitTest(m_o_x, m_o_y, true)) {
    if (xpoint_array>m_o_x) {
     hit_eara = "leg_left";
     break;
    }
   }
  } else if (head_right.hitTest(xpoint_array, ypoint_array, true)) {
   if (!head_right.hitTest(m_o_x, m_o_y, true)) {
    if (xpoint_array<m_o_x) {
     hit_eara = "head_right";
     break;
    }
   }
  } else if (arm_right.hitTest(xpoint_array, ypoint_array, true)) {
   if (!arm_right.hitTest(m_o_x, m_o_y, true)) {
    if (xpoint_array<m_o_x) {
     hit_eara = "arm_right";
     break;
    }
   }
  } else if (leg_right.hitTest(xpoint_array, ypoint_array, true)) {
   if (!leg_right.hitTest(m_o_x, m_o_y, true)) {
    if (xpoint_array<m_o_x) {
     hit_eara = "leg_right";
     break;
    }
   }
  }
}
}
function action() {
_root.motion_mc.gotoAndPlay(togo);
}
onEnterFrame = function () {
jsms();
poinv();
hit();
if (!ini) {
  hit_eara = "";
  ini = true;
}
switch (hit_eara) {
  case "head_left" :
   if (fj == w_h) {
    togo = "L_h_w";
   } else if (fj == m_h) {
    togo = "L_h_m";
   } else if (fj=s_h) {
    togo = "L_h_s";
   }
   action();
   hit_eara = "";
   break;
  case "head_right" :
   if (fj == w_h) {
    togo = "R_h_w";
   } else if (fj == m_h) {
    togo = "R_h_m";
   } else if (fj=s_h) {
    togo = "R_h_s";
   }
   action();
   hit_eara = "";
   break;
  case "arm_left" :
   if (fj == w_h) {
    togo = "L_a_w";
   } else if (fj == m_h) {
    togo = "L_a_m";
   } else if (fj=s_h) {
    togo = "L_a_s";
   }
   action();
   hit_eara = "";
   break;
  case "arm_right" :
   if (fj == w_h) {
    togo = "R_a_w";
   } else if (fj == m_h) {
    togo = "R_a_m";
   } else if (fj=s_h) {
    togo = "R_a_s";
   }
   action();
   hit_eara = "";
   break;
  case "leg_left" :
   if (fj == w_h) {
    togo = "L_l_w";
   } else if (fj == m_h) {
    togo = "l_m";
   } else if (fj=s_h) {
    togo = "L_l_s";
   }
   action();
   hit_eara = "";
   break;
  case "right_left" :
   if (fj == w_h) {
    togo = "R_l_w";
   } else if (fj == m_h) {
    togo = "l_m";
   } else if (fj=s_h) {
    togo = "R_l_s";
   }
   action();
   hit_eara = "";
   break;
}
};
回复

使用道具 举报

86

主题

250

帖子

390

积分

版主

Rank: 7Rank: 7Rank: 7

积分
390
发表于 2009-12-18 07:33:22 | 显示全部楼层
LZ还是把整个fla发上来吧。
或是附件或是网络硬盘dropbox.com

或者是去http://www.flash8.net求助,这里只有我一个人,有时忙就顾不及了。
回复 支持 反对

使用道具 举报

1

主题

2

帖子

23

积分

②入门

积分
23
 楼主| 发表于 2009-12-18 22:17:23 | 显示全部楼层
谢谢哈,我传上来,帮我看看~

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2024-3-29 02:57 , Processed in 0.025722 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表