改法有几种。
下面给出一种改法:
你看看
#encoding:utf-8 #============================================================================== # ■ Sprite_Character #------------------------------------------------------------------------------ # 地图人物的精灵。根据 Game_Character 类的实例自动变化。 #============================================================================== class Sprite_Character < Sprite_Base #-------------------------------------------------------------------------- # ● 释放 #-------------------------------------------------------------------------- def dispose end_animation end_balloon super @sprite_name.dispose if @sprite_name @window_talking.dispose if @window_talking end #-------------------------------------------------------------------------- # ● 更新位置 #-------------------------------------------------------------------------- def update_position self.x = @character.screen_x self.y = @character.screen_y self.z = @character.screen_z unless @sprite_name || @character.name[/EV/] || @character.name.size == 0 bitmap = Bitmap.new(1, 1) width = bitmap.text_size(@character.name).width + 6 bitmap.dispose if !$show_off @sprite_name = Sprite.new(self.viewport) @sprite_name.bitmap = Bitmap.new([width, 1].max, 12) @sprite_name.bitmap.font.shadow = true @sprite_name.bitmap.fill_rect(0, 0, width, 12, Color.new(0, 0, 0, 120)) @sprite_name.bitmap.draw_text(0, 0, width, 12, @character.name, 1) @sprite_name.ox = width / 2 @sprite_name.oy = 0 end end if @sprite_name @sprite_name.x = self.x @sprite_name.y = self.y @sprite_name.z = self.z end end #-------------------------------------------------------------------------- # ● 更新其他 #-------------------------------------------------------------------------- def update_other self.opacity = @character.opacity self.blend_type = @character.blend_type self.bush_depth = @character.bush_depth self.visible = !@character.transparent if @character.talking.size > 0 bitmap = Bitmap.new(1, 1) datas = [] x = 0 y = 0 while char = @character.talking.slice!(/./m) if x >= 144 x = 0 y += 1 end case char when "\n" x = 0 y += 1 next end x += bitmap.text_size(char).width datas[y] ||= "" datas[y] += char end bitmap.dispose @window_talking.dispose if @window_talking @window_talking = Window_Base.new(0, 0, (y > 0 ? 144 : x) + 32, y * 16 + 42) @window_talking.openness = 0 @window_talking.open for i in 0...datas.size data = datas[i] @window_talking.contents.draw_text(0, i * 16, @window_talking.contents.width, 16, data) end @counter_talking = 0 end if @window_talking && !@window_talking.disposed? @window_talking.update @window_talking.x = self.x - @window_talking.width / 2 @window_talking.y = self.y - @window_talking.height - 32 case (@counter_talking += 1) when 240 @window_talking.close end end end end
#encoding:utf-8
#==============================================================================
# ■ Sprite_Character
#------------------------------------------------------------------------------
# 地图人物的精灵。根据 Game_Character 类的实例自动变化。
#==============================================================================
class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
end_animation
end_balloon
super
@sprite_name.dispose if @sprite_name
@window_talking.dispose if @window_talking
end
#--------------------------------------------------------------------------
# ● 更新位置
#--------------------------------------------------------------------------
def update_position
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z
unless @sprite_name || @character.name[/EV/] || @character.name.size == 0
bitmap = Bitmap.new(1, 1)
width = bitmap.text_size(@character.name).width + 6
bitmap.dispose
if !$show_off
@sprite_name = Sprite.new(self.viewport)
@sprite_name.bitmap = Bitmap.new([width, 1].max, 12)
@sprite_name.bitmap.font.shadow = true
@sprite_name.bitmap.fill_rect(0, 0, width, 12, Color.new(0, 0, 0, 120))
@sprite_name.bitmap.draw_text(0, 0, width, 12, @character.name, 1)
@sprite_name.ox = width / 2
@sprite_name.oy = 0
end
end
if @sprite_name
@sprite_name.x = self.x
@sprite_name.y = self.y
@sprite_name.z = self.z
end
end
#--------------------------------------------------------------------------
# ● 更新其他
#--------------------------------------------------------------------------
def update_other
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
self.visible = !@character.transparent
if @character.talking.size > 0
bitmap = Bitmap.new(1, 1)
datas = []
x = 0
y = 0
while char = @character.talking.slice!(/./m)
if x >= 144
x = 0
y += 1
end
case char
when "\n"
x = 0
y += 1
next
end
x += bitmap.text_size(char).width
datas[y] ||= ""
datas[y] += char
end
bitmap.dispose
@window_talking.dispose if @window_talking
@window_talking = Window_Base.new(0, 0, (y > 0 ? 144 : x) + 32, y * 16 + 42)
@window_talking.openness = 0
@window_talking.open
for i in 0...datas.size
data = datas[i]
@window_talking.contents.draw_text(0, i * 16, @window_talking.contents.width, 16, data)
end
@counter_talking = 0
end
if @window_talking && !@window_talking.disposed?
@window_talking.update
@window_talking.x = self.x - @window_talking.width / 2
@window_talking.y = self.y - @window_talking.height - 32
case (@counter_talking += 1)
when 240
@window_talking.close
end
end
end
end
#encoding:utf-8 #============================================================================== # ■ Scene_Map #------------------------------------------------------------------------------ # 地图画面 #============================================================================== $show_off=true class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super SceneManager.clear $game_player.straighten $game_map.refresh $game_message.visible = false create_spriteset create_all_windows @menu_calling = false if !$show_off $game_mapui = Game_MapUI.new $game_mapui.update end end #-------------------------------------------------------------------------- # ● 结束处理 #-------------------------------------------------------------------------- def terminate super SceneManager.snapshot_for_background dispose_spriteset perform_battle_transition if SceneManager.scene_is?(Scene_Battle) $game_mapui.dispose if $game_mapui end #-------------------------------------------------------------------------- # ● 更新画面 #-------------------------------------------------------------------------- def update super $game_map.update(true) $game_player.update $game_timer.update @spriteset.update update_scene if scene_change_ok? $game_mapui.update if $game_mapui end def call_menu end end
#encoding:utf-8
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
# 地图画面
#==============================================================================
$show_off=true
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
SceneManager.clear
$game_player.straighten
$game_map.refresh
$game_message.visible = false
create_spriteset
create_all_windows
@menu_calling = false
if !$show_off
$game_mapui = Game_MapUI.new
$game_mapui.update
end
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
def terminate
super
SceneManager.snapshot_for_background
dispose_spriteset
perform_battle_transition if SceneManager.scene_is?(Scene_Battle)
$game_mapui.dispose if $game_mapui
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
$game_map.update(true)
$game_player.update
$game_timer.update
@spriteset.update
update_scene if scene_change_ok?
$game_mapui.update if $game_mapui
end
def call_menu
end
end
要改动两个插件,一个地图上显示信息,一个是在角色下显示名字
给加了个全局变量控制$show_off=true,不显示以上两者,置为false就可显示了。
|