涉及方法,Game_Player类中:
all_move_by_input
all_check_event_trigger_touch
all_move_down
all_move_left
all_move_right
all_move_up
all_move_lower_left
all_move_lower_right
all_move_upper_left
all_move_upper_right
def all_move_by_input
return unless movable?
return if $game_map.interpreter.running?
case Input.dir8
when 1; all_move_lower_left
when 2; all_move_down
when 3; all_move_lower_right
when 4; all_move_left
#when 5;
when 6; all_move_right
when 7; all_move_upper_left
when 8; all_move_up
when 9; all_move_upper_right
end
end
def all_move_down(turn_ok = true)
if passable?(@x, @y+1) # 可以通过
turn_down
@y = $game_map.round_y(@y+1)
@real_y = (@y-1)*256
increase_steps
@move_failed = false
else # 下方向不可通过
#如果存在事件优先启动。
if all_check_event_trigger_touch(@x, @y+1) # 判断接触的事件启动
turn_down if turn_ok
@move_failed = true
return
end
#判断相对主角左右方向移动情况
#(dir =1:顺时针第一方向可;dir =2:顺时针第二方向可;dir =3:二方向皆可。)
dir = 0
dir +=1 if passable?(@x+1, @y+1) #右下
dir +=2 if passable?(@x-1, @y+1) #左下
if dir > 0
#根据多数人右下优于左上的生理习惯,右下随机量略大于左上。
return (rand(10) > 4 ? all_move_lower_right : all_move_lower_left) if dir == 3
return all_move_lower_left if dir == 2
return all_move_lower_right if dir == 1
end
end
end
def all_check_event_trigger_touch(x, y)
return false if $game_map.interpreter.running?
result = false
allEvents = $game_map.events_xy(x, y)
#只要存在事件,无论是否可启动,必定为真,让移动停止。
result = true unless allEvents.empty?
for event in allEvents
if [1,2].include?(event.trigger) and event.priority_type == 1
event.start
end
end
return result
end
Game_Player类中
def update
last_real_x = @real_x
last_real_y = @real_y
last_moving = moving?
#全方向移动
all_move_by_input
super
update_scroll(last_real_x, last_real_y)
update_vehicle
update_nonmoving(last_moving)
end
以下引用snstar2006于2008-10-11 21:31:16的发言:
美受你发错区了....
转移
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |