def initialize
@pic = []
star
end
def star
#我没理解错是应该插在这里对吧
if $game_switches[1] == false
@viewport.visible = false #这个位置报错
else
@viewport.visible = true
end
#上面就是你说添加的部分!
width = $game_map.width
height = $game_map.height
@viewport = Viewport.new(MX,MY,GX*DX+1,GY*DX+1)
for i in 0..2
@pic[i] = Sprite.new(@viewport)
@pic[i].bitmap = Bitmap.new(width*DX+1,height*DX+1)
@pic[i].x = (GX - width)*DX if OO == 1
@pic[i].z = 50
end
@pic[0].bitmap.fill_rect(0,0,width*DX+1,height*DX+1, COLOR_A)
@pic[0].z -= 1
@pic[2].z += 1
@map = $game_map
for x in 0...width
for y in 0...height
next unless @map.pass?(x,y,0)
@pic[1].bitmap.fill_rect(x*DX+1,y*DX+1,DX-1,DX-1, COLOR_B)
if @map.pass?(x,y,2) and @map.pass?(x,y+1,8)
@pic[1].bitmap.fill_rect(x*DX+1,y*DX+DX,DX-1,1, COLOR_B)
else
@pic[1].bitmap.fill_rect(x*DX,y*DX+DX,DX+1,1, COLOR_C)
end
if @map.pass?(x,y,6) and @map.pass?(x+1,y,4)
@pic[1].bitmap.fill_rect(x*DX+DX,y*DX+1,1,DX-1, COLOR_B)
else
@pic[1].bitmap.fill_rect(x*DX+DX,y*DX,1,DX+1, COLOR_C)
end
unless @map.pass?(x,y-1,0)
@pic[1].bitmap.fill_rect(x*DX,y*DX,DX+1,1, COLOR_C)
end
unless @map.pass?(x-1,y,0)
@pic[1].bitmap.fill_rect(x*DX,y*DX,1,DX+1, COLOR_C)
end
next unless @map.pass?(x,y,6)
next unless @map.pass?(x,y,2)
next unless @map.pass?(x+1,y,4)
next unless @map.pass?(x+1,y,2)
next unless @map.pass?(x,y+1,8)
next unless @map.pass?(x,y+1,6)
next unless @map.pass?(x+1,y+1,8)
next unless @map.pass?(x+1,y+1,4)
@pic[1].bitmap.fill_rect(x*DX+DX,y*DX+DX,1,1, COLOR_B)
end
end
update
end
def update
@pic[2].bitmap.clear
for i in @map.events.keys
next if @map.events[i].list.size <= 1 # 没有行走图的事件隐藏
next if @map.events[i].character_name == "" # 没有执行内容的事件隐藏
next if @map.events[i].event.name == "" #没有事件名称的内容隐藏
color = EVENT_Z
color = EVENT_A[1] if @map.events[i].event.name == EVENT_A[0]
color = EVENT_B[1] if @map.events[i].event.name == EVENT_B[0]
color = EVENT_C[1] if @map.events[i].event.name == EVENT_C[0]
x = @map.events[i].x
y = @map.events[i].y
@pic[2].bitmap.fill_rect(x*DX+1,y*DX+1,DX-1,DX-1, color)
end
x = $game_player.x
y = $game_player.y
@pic[2].bitmap.fill_rect(x*DX+1,y*DX+1,DX-1,DX-1, EVENT_P)
if @map.width > GX
x = GX/2 if x < GX/2
x = @map.width - GX/2 if @map.width - x < GX/2
@pic[1].x = (GX/2 - x)*DX
@pic[2].x = (GX/2 - x)*DX
end
if @map.height > GY
y = GY/2 if y < GY/2
y = @map.height - GY/2 if @map.height - y < GY/2
@pic[1].y = (GY/2 - y)*DX
@pic[2].y = (GY/2 - y)*DX
end
end
end
#==============================================================================
# ● 默认脚本的更改
#==============================================================================
class Game_Map
def pass?(x, y, d)
for i in [2, 1, 0]
tile_id = data[x, y, i]
return false if tile_id == nil
return false if @passages[tile_id] & ((1 << (d / 2 - 1)) & 0x0f) != 0
return false if @passages[tile_id] & 0x0f == 0x0f
return true if @priorities[tile_id] == 0
end
end
end
class Game_Event < Game_Character
attr_reader :event
end
#添加显示与刷新
class Scene_Map
def main
@spriteset = Spriteset_Map.new
@message_window = Window_Message.new
@midmap = Midmap.new #★★★
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@spriteset.dispose
@message_window.dispose
if $scene.is_a?(Scene_Title)
Graphics.transition
Graphics.freeze
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
loop do
$game_map.update
$game_system.map_interpreter.update
$game_player.update
$game_system.update
$game_screen.update
unless $game_temp.player_transferring
break
end
transfer_player
if $game_temp.transition_processing
break
end
end
@spriteset.update
@message_window.update
@midmap.update #★★★
if $game_temp.gameover
$scene = Scene_Gameover.new
return
end
if $game_temp.to_title
$scene = Scene_Title.new
return
end
if $game_temp.transition_processing
$game_temp.transition_processing = false
if $game_temp.transition_name == ""
Graphics.transition(20)
else
Graphics.transition(60, "Graphics/Transitions/" +
$game_temp.transition_name)
end
end
if $game_temp.message_window_showing
return
end
if $game_player.encounter_count == 0 and $game_map.encounter_list != []
unless $game_system.map_interpreter.running? or
$game_system.encounter_disabled
n = rand($game_map.encounter_list.size)
troop_id = $game_map.encounter_list[n]
if $data_troops[troop_id] != nil
$game_temp.battle_calling = true
$game_temp.battle_troop_id = troop_id
$game_temp.battle_can_escape = true
$game_temp.battle_can_lose = false
$game_temp.battle_proc = nil
end
end
end
if Input.trigger?(Input::B)
unless $game_system.map_interpreter.running? or
$game_system.menu_disabled
$game_temp.menu_calling = true
$game_temp.menu_beep = true
end
end
if $DEBUG and Input.press?(Input::F9)
$game_temp.debug_calling = true
end
unless $game_player.moving?
if $game_temp.battle_calling
call_battle
elsif $game_temp.shop_calling
call_shop
elsif $game_temp.name_calling
call_name
elsif $game_temp.menu_calling
call_menu
elsif $game_temp.save_calling
call_save
elsif $game_temp.debug_calling
call_debug
end
end
end
#--------------------------------------------------------------------------
# ● 主角的场所移动
#--------------------------------------------------------------------------
def transfer_player
$game_temp.player_transferring = false
if $game_map.map_id != $game_temp.player_new_map_id
$game_map.setup($game_temp.player_new_map_id)
end
$game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
case $game_temp.player_new_direction
when 2
$game_player.turn_down
when 4
$game_player.turn_left
when 6
$game_player.turn_right
when 8
$game_player.turn_up
end
$game_player.straighten
$game_map.update
@spriteset.dispose
@spriteset = Spriteset_Map.new
@midmap.star #★★★
if $game_temp.transition_processing
$game_temp.transition_processing = false
Graphics.transition(20)
end
$game_map.autoplay
Graphics.frame_reset
Input.update
end
end
提示:
undefinen method ‘visible=’ for nil:Nilclass作者: well 时间: 2009-11-9 13:42
我晕,看来位置很重要。但我以为你至少会加在实例创建之后。
咳,在你插的那个位置往下3行,有一行内容是
@viewport = Viewport.new(MX,MY,GX*DX+1,GY*DX+1)
我加的东西要放在它下面。作者: 魏玉龙 时间: 2009-11-9 16:40
:victory:终于不报错了~!
但是小地图也成功消失了
怎么打开 开关 关不开关
都不会显示了~!我晕一个先~!作者: well 时间: 2009-11-9 17:09 10#魏玉龙
我又忘了刷新的问题了……测试时都是用F9改的。
呃。把那段脚本放到 class Midmap 的def update里。这回应该没问题了。