那么,我来帮你翻译这些代码:
function PlayerState_Attack_Magic(){
hspeed = 0;
vspeed = 0;
//攻击动画开始
if (sprite_index != player1attack){
sprite_index = player1attack;
image_index = 0;
ds_list_clear(hitByAttack);
}
//使用攻击 hitbox & 检测碰撞
mask_index = player1attackHB;
var hitByAttackNow = ds_list_create();
var hits = instance_place_list(x,y,oEnemy,hitByAttackNow,false);
if (hits > 0){
for (var i = 0; i < hits; i++){
if (ds_list_find_index(hitByAttack,hitID) == -1){
ds_list_add(hitByAttack,hitID);
with (hitID){
EnemyHit(2);
}
}
}
}
ds_list_destroy(hitByAttackNow);
mask_index = player1;
if (animation_end()){
sprite_index = player1;
state = PLAYERSTATE.FREE;
}
}
function PlayerState_Free(){
//水平移动
//方向
moveDir = rightKey - leftKey;
//求x运动速度
xspd = moveDir * moveSpd;
//水平碰撞
var _subPixel = .5;
if (place_meeting( x + xspd, y, Obj_block )({
//
//精确移动到墙上
var _pixelCheck = _subPixel sign(xspd);
while (!place_meeting( x + _pixelCheck, y, Obj_block)){
x += _pixelCheck;
}
//
//设置x速度为零以“碰撞”
xspd = 0;
}
//移动
x += xspd;
//垂直移动
//重力
yspd += grav;
//
//降落速度限制
if (yspd > termVel) { yspd = termVel; };
//
//跳跃
if (jumpKeyPressed && place_meeting( x, y+1, Obj_block )){
yspd = jspd;
}
//
//垂直碰撞
if (place_meeting( x, y + yspd, Obj_block )){
//
//精确移动到墙上
var _pixelCheck = _subPixel * sign(yspd);
while (!place_meeting(x, y + _pixelCheck, Obj_block ))
{
y += _pixelCheck;
}
//
//设置yspd为零以“碰撞”
yspd = 0;
}
//移动
y += yspd;
//动作
if (keyboard_check(vk_right)){
x+=1;
sprite_index = player1;
image_xscale = 2;
}
//
if (keyboard_check(vk_left)){
x-=1;
sprite_index = player1;
image_xscale = -2;
/
}
//
if (keyAttack) state = PLAYERSTATE.ATTACK_MAGIC;
}
function animation_end(){
var _sprite=sprite_index;
var _image=image_index;
if (argument_count > 0) _sprite=argument[0];
if (argument_count > 1) _image=argument[1];
var _type=sprite_get_speed_type(sprite_index)
var _spd=sprite_get_speed(sprite_index)*image_speed;
if (_type == spritespeed_framespersecond)
_spd = _spd/room_speed;
if (argument_count > 2) _spd=argument[2];
return _image+_spd >= sprite_get_number(_sprite);
}
这些是你目前拥有的三个脚本。
评论 (0)