我用把方向鼠标脚本开始的时候不能选择
我用把方向脚本,但是刚开始的时候鼠标不能选择只能按确定,就是说鼠标脚本在开头进入游戏的时候不能选择开始或结束只能用键盘选择,有什么方法可以解决吗?这是我的开头脚本#==============================================================================# ■ Scene_Title
#------------------------------------------------------------------------------
# 处理标题画面的类。
#==============================================================================
class Scene_Title
Start_Map_ID = 1 #——新手指导地图编号
Start_X = 5 #——坐标
Start_Y = 5 #——坐标
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 战斗测试的情况下
if $BTEST
battle_test
return
end
# 载入数据库
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
# 生成系统对像
$game_system = Game_System.new
# 进入事件显示LOGO,如果您不想在调试时总是显示LOGO就加上下一行中注释部分
if $show_logo # and !$DEBUG
# 设置标记变量保证下次回到标题画面不会再显示片头
$show_logo = false
# 重置测量游戏时间用的画面计数器
Graphics.frame_count = 0
# 生成各种游戏对像
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# 设置初期同伴位置
$game_party.setup_starting_members
# 设置初期位置的地图
$game_map.setup($data_system.start_map_id)
# 主角向初期位置移动
$game_player.moveto($data_system.start_x, $data_system.start_y)
# 刷新主角
$game_player.refresh
# 执行地图设置的 BGM 与 BGS 的自动切换
$game_map.autoplay
# 刷新地图 (执行并行事件)
$game_map.update
# 与真正的新游戏唯一不同就是将变量1设置一个标记值(暂用8764)
$game_variables=8764
# 主角暂时是不能显示出来的……
$game_player.transparent = true
# 切换地图画面
$scene = Scene_Map.new
# 否则是默认显示标题画面
else
# 生成标题图形
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
# 生成标题图形
@sprite =
for i in 0..8
@sprite = Sprite.new
@sprite.opacity = 0
end
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
@sprite.opacity = 0
#开始游戏的图片
@sprite.bitmap = Bitmap.new("Graphics/Pictures/11.png")
@sprite.bitmap = Bitmap.new("Graphics/Pictures/12.png")
#继续游戏的图片
@sprite.bitmap = Bitmap.new("Graphics/Pictures/21.png")
@sprite.bitmap = Bitmap.new("Graphics/Pictures/22.png")
#新手指导
@sprite.bitmap = Bitmap.new("Graphics/Pictures/41.png")
@sprite.bitmap = Bitmap.new("Graphics/Pictures/42.png")
#结束游戏的图片
@sprite.bitmap = Bitmap.new("Graphics/Pictures/31.png")
@sprite.bitmap = Bitmap.new("Graphics/Pictures/32.png")
#图片位置
for i in 1..8
x=80
y=(i+1)/2*60+120
@sprite.x =x
@sprite.y =y
end
@continue_enabled = false
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
@continue_enabled = true
end
end
if @continue_enabled
@command_index = 1
else
@command_index = 0
@sprite.tone = Tone.new(0, 0, 0, 255)
@sprite.tone = Tone.new(0, 0, 0, 255)
end
$game_system.bgm_play($data_system.title_bgm)
Audio.me_stop
Audio.bgs_stop
Graphics.transition
loop do
Graphics.update
#淡出背景圖形
if @sprite.opacity <= 255
@sprite.opacity += 15
end
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
# 釋放圖形
for i in 0..8
@sprite.bitmap.dispose
@sprite.dispose
end
end
def update
chaochaocommandchaochao
if Input.trigger?(Input::C)
case @command_index
when 0
command_new_game
when 1
command_continue
when 2
command_help
when 3
command_shutdown
end
end
end
def chaochaocommandchaochao
if Input.trigger?(Input::UP)
@command_index -= 1
if @command_index < 0
@command_index = 3
end
$game_system.se_play($data_system.cursor_se)
end
if Input.trigger?(Input::DOWN)
@command_index += 1
if @command_index > 3
@command_index = 0
end
$game_system.se_play($data_system.cursor_se)
end
case @command_index
when 0
if @sprite.opacity >= 0
@sprite.opacity -= 30
end
if @sprite.opacity <= 240
@sprite.opacity += 30
end
if @sprite.opacity <= 210
@sprite.opacity += 30
end
if @sprite.opacity >= 0
@sprite.opacity -= 30
end
if @sprite.opacity <= 210
@sprite.opacity += 30
end
if @sprite.opacity >= 0
@sprite.opacity -= 30
end
if @sprite.opacity <= 210
@sprite.opacity +=30
end
if @sprite.opacity >= 0
@sprite.opacity -=30
end
when 1
if @sprite.opacity <= 210
@sprite.opacity += 30
end
if @sprite.opacity >= 0
@sprite.opacity -= 30
end
if @sprite.opacity >= 0
@sprite.opacity -= 30
end
if @sprite.opacity <= 240
@sprite.opacity += 30
end
if @sprite.opacity <= 210
@sprite.opacity += 30
end
if @sprite.opacity >= 0
@sprite.opacity -= 30
end
if @sprite.opacity <= 210
@sprite.opacity +=30
end
if @sprite.opacity >=0
@sprite.opacity -=30
end
when 2
if @sprite.opacity <= 210
@sprite.opacity += 30
end
if @sprite.opacity >= 0
@sprite.opacity -= 30
end
if @sprite.opacity <= 210
@sprite.opacity += 30
end
if @sprite.opacity >= 0
@sprite.opacity -= 30
end
if @sprite.opacity >= 0
@sprite.opacity -= 30
end
if @sprite.opacity <= 240
@sprite.opacity += 30
end
if @sprite.opacity <= 210
@sprite.opacity +=30
end
if @sprite.opacity >=0
@sprite.opacity -=30
end
when 3
if @sprite.opacity <= 210
@sprite.opacity += 30
end
if @sprite.opacity >= 0
@sprite.opacity -= 30
end
if @sprite.opacity <= 210
@sprite.opacity += 30
end
if @sprite.opacity >=0
@sprite.opacity -= 30
end
if @sprite.opacity <= 210
@sprite.opacity += 30
end
if @sprite.opacity >=0
@sprite.opacity -= 30
end
if @sprite.opacity >= 0
@sprite.opacity -=30
end
if @sprite.opacity <= 240
@sprite.opacity += 30
end
end
end
end
#--------------------------------------------------------------------------
# ● 命令 : 新游戏
#--------------------------------------------------------------------------
def command_new_game
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 停止 BGM
Audio.bgm_stop
# 重置测量游戏时间用的画面计数器
Graphics.frame_count = 0
# 生成各种游戏对像
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# 设置初期同伴位置
$game_party.setup_starting_members
# 设置初期位置的地图
$game_map.setup($data_system.start_map_id)
# 主角向初期位置移动
$game_player.moveto($data_system.start_x, $data_system.start_y)
# 刷新主角
$game_player.refresh
# 执行地图设置的 BGM 与 BGS 的自动切换
$game_map.autoplay
# 刷新地图 (执行并行事件)
$game_map.update
# 主角暂时是不能显示出来的……
$game_player.transparent = true
# 切换地图画面
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 命令 : 继续
#--------------------------------------------------------------------------
def command_continue
# 继续无效的情况下
unless @continue_enabled
# 演奏无效 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到读档画面
$scene = Scene_Load.new
end
#--------------------------------------------------------------------------
# ● 命令 : 新手指导
#--------------------------------------------------------------------------
def command_help
$game_system.se_play($data_system.decision_se)
Audio.bgm_stop
Graphics.frame_count = 0
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
$game_party.setup_starting_members
$game_map.setup(15)
$game_player.moveto(Start_X, Start_Y)
$game_player.refresh
$game_map.autoplay
$game_map.update
$game_player.transparent = true
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 命令 : 退出
#--------------------------------------------------------------------------
def command_shutdown
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# BGM、BGS、ME 的淡入淡出
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# 退出
$scene = nil
end
#--------------------------------------------------------------------------
# ● 战斗测试
#--------------------------------------------------------------------------
def battle_test
# 载入数据库 (战斗测试用)
$data_actors = load_data("Data/BT_Actors.rxdata")
$data_classes = load_data("Data/BT_Classes.rxdata")
$data_skills = load_data("Data/BT_Skills.rxdata")
$data_items = load_data("Data/BT_Items.rxdata")
$data_weapons = load_data("Data/BT_Weapons.rxdata")
$data_armors = load_data("Data/BT_Armors.rxdata")
$data_enemies = load_data("Data/BT_Enemies.rxdata")
$data_troops = load_data("Data/BT_Troops.rxdata")
$data_states = load_data("Data/BT_States.rxdata")
$data_animations = load_data("Data/BT_Animations.rxdata")
$data_tilesets = load_data("Data/BT_Tilesets.rxdata")
$data_common_events = load_data("Data/BT_CommonEvents.rxdata")
$data_system = load_data("Data/BT_System.rxdata")
# 重置测量游戏时间用的画面计数器
Graphics.frame_count = 0
# 生成各种游戏对像
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# 设置战斗测试用同伴
$game_party.setup_battle_test_members
# 设置队伍 ID、可以逃走标志、战斗背景
$game_temp.battle_troop_id = $data_system.test_troop_id
$game_temp.battle_can_escape = true
$game_map.battleback_name = $data_system.battleback_name
# 演奏战斗开始 BGM
$game_system.se_play($data_system.battle_start_se)
# 演奏战斗 BGM
$game_system.bgm_play($game_system.battle_bgm)
# 切换到战斗画面
$scene = Scene_Battle.new
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
鼠标脚本#==============================================================================
# ■ Find_Path
#------------------------------------------------------------------------------
# 寻路算法--完整鼠标系统(八方向)专用版
# By whbm
#==============================================================================
class Find_Path
#--------------------------------------------------------------------------
def initialize#初始化
@open_list = []
@close_lise = []
@path = []
end#结束初始化
#--------------------------------------------------------------------------
def fp_passable?(x, y, d, tr_x = -2, tr_y = -2)#开始判定通行
return false if (tr_x == @unable_xa or
tr_x == @unable_xb or
tr_y == @unable_ya or
tr_y == @unable_yb)
if .include?(d)
if $game_player.passable?(x, y, d)
return true
else
return false
end
else
case d
when 1
if ($game_player.passable?(x, y, 4) and
$game_player.passable?(x - 1, y, 2)) or
($game_player.passable?(x, y, 2) and
$game_player.passable?(x, y + 1, 4))
return true
else
return false
end
when 3
if ($game_player.passable?(x, y, 6) and
$game_player.passable?(x + 1, y, 2)) or
($game_player.passable?(x, y, 2) and
$game_player.passable?(x, y + 1, 6))
return true
else
return false
end
when 7
if ($game_player.passable?(x, y, 4) and
$game_player.passable?(x - 1, y, 8)) or
($game_player.passable?(x, y, 8) and
$game_player.passable?(x, y - 1, 4))
return true
else
return false
end
when 9
if ($game_player.passable?(x, y, 6) and
$game_player.passable?(x + 1, y, 8)) or
($game_player.passable?(x, y, 8) and
$game_player.passable?(x, y - 1, 6))
return true
else
return false
end
end
end
end#结束判定通行
#--------------------------------------------------------------------------
def get_g(now_point)#开始计算G值
d = now_point
return 0 if d == 5
father_point = get_father_point(now_point)
g = father_point + ((d == 1 or d == 3 or d == 7 or d == 9) ? 14 : 10)
return g
end#结束计算G值
#--------------------------------------------------------------------------
def get_h(now_point)#开始计算H值
now_x = now_point
now_y = now_point
#print @trg_x,now_x,@trg_y,now_y
h = (@trg_x - now_x).abs + (@trg_y - now_y).abs
return h * 10
end#结束计算H值
#--------------------------------------------------------------------------
def get_f(now_point)#开始计算F值
f = now_point + now_point
return f
end#结束计算F值
#--------------------------------------------------------------------------
def get_point(x, y) #取已知坐标点
if @open_list.size != 0
@open_list.each do |point|
if point == x and point == y
return point
break
end
end
end
if @close_list.size != 0
@close_list.each do |point|
if point == x and point == y
return point
break
end
end
end
end#结束取已知坐标点
#--------------------------------------------------------------------------
def get_father_point(now_point)#取已知点的父节点
d = now_point
return now_point if d == 5
x = now_point + ((d == 9 or d == 6 or d == 3) ? 1 : ((d == 7 or d == 4 or d == 1) ? -1 : 0))
y = now_point + ((d == 1 or d == 2 or d == 3) ? 1 : ((d == 7 or d == 8 or d == 9) ? -1 : 0))
return get_point(x, y)
end#结束取已知点的父节点
#--------------------------------------------------------------------------
def new_point(x, y, d)#开始建立新节点
#print x,y,d
point =
point.push get_g(point)
point.push get_h(point)
point.push get_f(point)
return point
end#结束建立新节点
#--------------------------------------------------------------------------
def get_direction(self_x, self_y, trg_x, trg_y)
if trg_x > self_x
if trg_y - self_y > - 0.4 * ( trg_x - self_x ) and
trg_y - self_y < 0.4 * ( trg_x - self_x )
return 6
end
if trg_y - self_y > 0.4 * ( trg_x - self_x ) and
trg_y - self_y < 2.4 * ( trg_x - self_x )
return 3
end
if trg_y - self_y < - 0.4 * ( trg_x - self_x ) and
trg_y - self_y > - 2.4 * ( trg_x - self_x )
return 9
end
if trg_y - self_y > 2.4 * ( trg_x - self_x )
return 2
end
if trg_y - self_y < - 2.4 * ( trg_x - self_x )
return 8
end
end
if trg_x < self_x
if trg_y - self_y > - 0.4 * ( self_x - trg_x ) and
trg_y - self_y < 0.4 * ( self_x - trg_x )
return 4
end
if trg_y - self_y > 0.4 * ( self_x - trg_x ) and
trg_y - self_y < 2.4 * ( self_x - trg_x )
return 1
end
if trg_y - self_y < - 0.4 * ( self_x - trg_x ) and
trg_y - self_y > - 2.4 * ( self_x - trg_x )
return 7
end
if trg_y - self_y > 2.4 * ( self_x - trg_x )
return 2
end
if trg_y - self_y < - 2.4 * ( self_x - trg_x )
return 8
end
end
end
#--------------------------------------------------------------------------
def get_d_x_y(x, y, d)
d_x = x + ((d == 9 or d == 6 or d == 3) ? 1 : ((d == 7 or d == 4 or d == 1) ? -1 : 0))
d_y = y + ((d == 1 or d == 2 or d == 3) ? 1 : ((d == 7 or d == 8 or d == 9) ? -1 : 0))
return d_x, d_y
end
#--------------------------------------------------------------------------
def find_short_path_other(self_x, self_y, trg_x, trg_y,
real_self_x, real_self_y, real_trg_x, real_trg_y)
@self_x = self_x
@self_y = self_y
@now_x = self_x
@now_y = self_y
@trg_x = trg_x
@trg_y = trg_y
@path = []
direction = get_direction(real_self_x, real_self_y, real_trg_x, real_trg_y)
@now_trg_x, @now_trg_y = get_d_x_y(@self_x, @self_y, direction)
while fp_passable?(@now_x, @now_y, direction)
@path.push direction
@now_x = @now_trg_x
@now_y = @now_trg_y
@now_trg_x, @now_trg_y = get_d_x_y(@now_x, @now_y, direction)
end
return @path
end
#--------------------------------------------------------------------------
def find_short_path(self_x, self_y, trg_x, trg_y,
real_self_x, real_self_y, real_trg_x, real_trg_y)#开始搜索路径
return find_short_path_other(self_x, self_y, trg_x, trg_y,
real_self_x, real_self_y, real_trg_x, real_trg_y) if not
(fp_passable?(trg_x, trg_y + 1, 8) or
fp_passable?(trg_x + 1, trg_y, 4) or
fp_passable?(trg_x - 1, trg_y, 6) or
fp_passable?(trg_x, trg_y - 1, 2)) and @goal_type != 1
#根据屏幕限定搜索面积..加速
@unable_xa = $game_map.display_x / 128 - 1
@unable_ya = $game_map.display_y / 128 - 1
@unable_xb = $game_map.display_x / 128 + 20
@unable_yb = $game_map.display_y / 128 + 20
@self_x = self_x
@self_y = self_y
@now_x = self_x
@now_y = self_y
@trg_x = trg_x
@trg_y = trg_y
@open_list = []
@close_list = []
#准备搜索
#print @self_x,@self_y
@now_point = new_point(@self_x, @self_y, 5) #令起始点为当前点
@open_list.push @now_point #将当前点加入关闭列表
#开始搜索
begin
loop do
check_trg = check_around_point(@now_point)
if check_trg == true
@path = get_path
break
end
@now_point = get_lowest_f_point
if @now_point == [] or @now_point == nil
@path = []
break
end
end
rescue Hangup
retry
end
return @path
end#结束搜索路径
#--------------------------------------------------------------------------
def find_player_short_path(trg_x, trg_y,
real_trg_x, real_trg_y)#寻找角色的最短路径
self_x = $game_player.x
self_y = $game_player.y
real_self_x = $game_player.screen_x
real_self_y = $game_player.screen_y
@goal_type, event = $game_map.check_event_custom_exist(real_trg_x, real_trg_y)
if @goal_type == 1
trg_x = event.x
trg_y = event.y
end
return find_short_path(self_x, self_y, trg_x, trg_y,
real_self_x, real_self_y, real_trg_x, real_trg_y)
end#结束角色的寻找路径
#--------------------------------------------------------------------------
def get_path#取得最终的路径
path = []
now_point = @open_list[@open_list.size - 1]
path.push(10 - now_point)
last_point = now_point
loop do
now_point = get_father_point(now_point)
break if now_point == 5
path.push(10 - now_point)
end
return path.reverse
end#结束取得最终的路径
#--------------------------------------------------------------------------
def get_lowest_f_point#开始取得最低F值的点
if @open_list == []
return []
end
last_lowest_f_point = @open_list
@open_list.each do |point|
last_lowest_f_point = point if point < last_lowest_f_point
end
return last_lowest_f_point
end#结束取得最低F值点
#--------------------------------------------------------------------------
def check_around_point(point)#开始检查已知点的八方节点
for d in
x = point + ((d == 9 or d == 6 or d == 3) ? 1 : ((d == 7 or d == 4 or d == 1) ? -1 : 0))
y = point + ((d == 1 or d == 2 or d == 3) ? 1 : ((d == 7 or d == 8 or d == 9) ? -1 : 0))
if in_close_list?(x, y) #在关闭列表中
next
elsif in_open_list?(x, y) #在开启列表中
get_new_g_point = new_point(x, y, 10 - d)
get_last_g_point = get_point(x, y)
if get_new_g_point >= get_last_g_point
next
else
#如果改变父节点是新G值更小则确定改变
@open_list[@open_list.index(get_last_g_point)] = get_new_g_point
end
else
if fp_passable?(point, point, d, x, y)
# 如果不在开启列表中、且不在关闭列表中、且通行则添加它到新八周节点
@open_list.push new_point(x, y, 10 - d)
#如果将目标点添加到了开启列表中就返回true
return true if x == @trg_x and y == @trg_y
return true if @goal_type == 1 and .include?(x - @trg_x) and .include?(y - @trg_y)
end
end
end
#此刻没有找到目标点并将当前点加入关闭列表并在开启列表中删除
@close_list.push point
@open_list.delete(point)
#此刻没找到目标点并返回false
return false
end#结束计算已知点的八方节点
#--------------------------------------------------------------------------
def in_open_list?(x, y)#开始检查谋点是否在开启列表中
@open_list.each do |point|
return true if point == x and point == y
end
return false
end#结束检查谋点是否在开启列表中
#--------------------------------------------------------------------------
def in_close_list?(x, y)#开始检查谋点是否在关闭列表中
@close_list.each do |point|
return true if point == x and point == y
end
return false
end#结束检查谋点是否在关闭列表中
#--------------------------------------------------------------------------
end
页:
[1]