查看: 3338|回复: 3

[已经解决] 高手们求帮忙~.....小地图问题

[复制链接]
梦石
0
星屑
50
在线时间
105 小时
注册时间
2013-1-24
回帖
100
发表于 2013-2-1 20:52:08 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
在论坛找了个小地图脚本。
在场所移动的时候就出现问题了- -
如图
1.jpg
请问是怎么回事??
脚本在下面
[pre lang="ruby" line="1"]#==============================================================================

# ■ 縮小地图的表示

#==============================================================================

#==============================================================================

# □ 前期定义

#==============================================================================

module PLAN_Map_Window

  WIN_X       = 8         # 窗口的初始 X 座標

  WIN_Y       = 8         # 窗口的初始 Y 座標

  WIN_WIDTH   = 6*32      # 地图的宽度

  WIN_HEIGHT  = 4*32      # 地图的高度

  ZOOM        = 4.0       # 地图的放缩比例

  WINDOWSKIN  = ""        # 自定义地图窗口素材,如果留空则是默认的

  ON_OFF_KEY  = Input::X  # 打开地图的按钮,X就是键盘的A键

  SWITCH      = 49      # 打开此号开关才可以使用小地图

                          # 使用地图功能,关闭则可以使用地图功能

  WINDOW_MOVE = true      # 是否可以自动改变窗口位置(true:可改变, false:固定)

  OVER_X      = 632 - WIN_WIDTH   # 自动改变后窗口的位置x

  OVER_Y      = 8       #自动改变后窗口的位置y



  OPACITY     = 180       # 窗口的透明度

  C_OPACITY   = 180       # 地图的透明度

  VISIBLE     = false     # 最初是否可见

end

#==============================================================================

# ■ Game_Temp

#==============================================================================

class Game_Temp

attr_accessor :map_visible

alias plan_map_window_initialize initialize

def initialize

plan_map_window_initialize

@map_visible = false

end

end

#==============================================================================

# ■ Scene_Map

#==============================================================================

class Scene_Map

#--------------------------------------------------------------------------

# ● 主处理

#--------------------------------------------------------------------------

alias plan_map_window_main main

def main

@map_window = Window_Map.new

@map_window.visible = $game_temp.map_visible

plan_map_window_main

@map_window.dispose

end

#--------------------------------------------------------------------------

# ● 更新

#--------------------------------------------------------------------------

alias plan_map_window_update update

def update

$game_temp.map_visible = @map_window.visible

plan_map_window_update

unless $game_switches[PLAN_Map_Window::SWITCH]==false

if Input.trigger?(PLAN_Map_Window::ON_OFF_KEY)

if @map_window.visible

@map_window.visible = false

else

@map_window.visible = true

end

end

else

if @map_window.visible

@map_window.visible = false

end

end

if @map_window.visible

@map_window.update

end

end

#--------------------------------------------------------------------------

# ● 场所移动的变化

#--------------------------------------------------------------------------

alias plan_map_window_transfer_player transfer_player

def transfer_player

visible = @map_window.visible

@map_window.visible = false

plan_map_window_transfer_player

@map_window.dispose

@map_window = Window_Map.new

@map_window.visible = visible

end

end

#==============================================================================

# ■ Window_Map

#==============================================================================

class Window_Map < Window_Base

#--------------------------------------------------------------------------

# ● 初始化

#--------------------------------------------------------------------------

def initialize

x = PLAN_Map_Window::WIN_X

y = PLAN_Map_Window::WIN_Y

w = PLAN_Map_Window::WIN_WIDTH

h = PLAN_Map_Window::WIN_HEIGHT

super(x, y, w, h)

unless PLAN_Map_Window::WINDOWSKIN.empty?

self.windowskin = RPG::Cache.windowskin(PLAN_Map_Window::WINDOWSKIN)

end

self.contents = Bitmap.new(width - 32, height - 32)

self.opacity = PLAN_Map_Window::OPACITY

self.contents_opacity = PLAN_Map_Window::C_OPACITY

@map_data = $game_map.data

@tileset = RPG::Cache.tileset($game_map.tileset_name)

@autotiles = []

for i in 0..6

autotile_name = $game_map.autotile_names

@autotiles = RPG::Cache.autotile(autotile_name)

end

@old_real_x = $game_player.real_x

@old_real_y = $game_player.real_y

@all_map = make_all_map

self.visible = PLAN_Map_Window::VISIBLE

refresh

end

#--------------------------------------------------------------------------

# ● 缩小图做成

#--------------------------------------------------------------------------

def make_all_map

all_map = Bitmap.new($game_map.width * 32, $game_map.height * 32)

for y in 0...$game_map.height

for x in 0...$game_map.width

for z in 0...3

tile_num = @map_data[x, y, z]

next if tile_num == nil

if tile_num < 384

if tile_num >= 48

tile_num -= 48

src_rect = Rect.new(32, 2 * 32, 32, 32)

all_map.blt(x * 32, y * 32, @autotiles[tile_num / 48], src_rect)

end

else

tile_num -= 384

src_rect = Rect.new(tile_num % 8 * 32, tile_num / 8 * 32, 32, 32)

all_map.blt(x * 32, y * 32, @tileset, src_rect)

end

end

end

end

w = ($game_map.width / PLAN_Map_Window::ZOOM) * 32

h = ($game_map.height / PLAN_Map_Window::ZOOM) * 32

ret_bitmap = Bitmap.new(w, h)

src_rect = Rect.new(0, 0, all_map.width, all_map.height)

dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)

ret_bitmap.stretch_blt(dest_rect, all_map, src_rect)

all_map.dispose

return ret_bitmap

end

#--------------------------------------------------------------------------

# ● 刷新

#--------------------------------------------------------------------------

def refresh

self.contents.clear

one_tile_size = 32 / PLAN_Map_Window::ZOOM

x = $game_player.real_x - 128 * (self.contents.width / one_tile_size) / 2

y = $game_player.real_y - 128 * (self.contents.height / one_tile_size) / 2

x = x * one_tile_size / 128

y = y * one_tile_size / 128

half_width = self.contents.width * 128 / 2

rest_width = ($game_map.width * 128 - $game_player.real_x) * one_tile_size

rev_x = 0

if @all_map.width < self.contents.width

rev_x = (half_width - $game_player.real_x * one_tile_size) / 128

rev_x -= (self.contents.width - @all_map.width) / 2

x += rev_x

elsif half_width > $game_player.real_x * one_tile_size

rev_x = (half_width - $game_player.real_x * one_tile_size) / 128

x += rev_x

elsif half_width > rest_width

rev_x = -((half_width - rest_width) / 128)

x += rev_x

end

half_height = self.contents.height * 128 / 2

rest_height = ($game_map.height * 128 - $game_player.real_y) * one_tile_size

rev_y = 0

if @all_map.height < self.contents.height

rev_y = (half_height - $game_player.real_y * one_tile_size) / 128

rev_y -= (self.contents.height - @all_map.height) / 2

y += rev_y

elsif half_height > $game_player.real_y * one_tile_size

rev_y = (half_height - $game_player.real_y * one_tile_size) / 128

y += rev_y

elsif half_height > rest_height

rev_y = -((half_height - rest_height) / 128)

y += rev_y

end

src_rect = Rect.new(x, y, self.contents.width, self.contents.height)

self.contents.blt(0, 0, @all_map, src_rect)

if PLAN_Map_Window::WINDOW_MOVE == true

w = self.x..self.x + self.width

h = self.y..self.y + self.height

if w === $game_player.screen_x and h === $game_player.screen_y

if self.x == PLAN_Map_Window::WIN_X and self.y == PLAN_Map_Window::WIN_Y

self.x = PLAN_Map_Window::OVER_X

self.y = PLAN_Map_Window::OVER_Y

else

self.x = PLAN_Map_Window::WIN_X

self.y = PLAN_Map_Window::WIN_Y

end

end

end

if $game_party.actors.size > 0

for i in [2, 1, 0]

tile = @map_data[$game_player.x, $game_player.y, i]

next if tile == 0

return if $game_map.priorities[tile] > 0

end

actor = $game_party.actors[0]

bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)

width = bitmap.width / 4

height = bitmap.height / 4

src_rect = Rect.new(0, 0, width, height)

w = width / PLAN_Map_Window::ZOOM

h = height / PLAN_Map_Window::ZOOM

x = self.contents.width / 2 - w / 2 + one_tile_size / 2 - rev_x

y = self.contents.height / 2 - h / 2 - rev_y

dest_rect = Rect.new(x, y, w, h)

self.contents.stretch_blt(dest_rect, bitmap, src_rect)

end

end

#--------------------------------------------------------------------------

# ● 更新

#--------------------------------------------------------------------------

def update

super

if @old_real_x != $game_player.real_x or @old_real_y != $game_player.real_y

@old_real_x = $game_player.real_x

@old_real_y = $game_player.real_y

refresh

end

end

#--------------------------------------------------------------------------

# ● 解放

#--------------------------------------------------------------------------

def dispose

super

@all_map.dispose

end

end

#==============================================================================

# ■ Window_Menu_Command

#==============================================================================

class Window_Menu_Command < Window_Selectable

#--------------------------------------------------------------------------

# map_id : 地图 ID

#--------------------------------------------------------------------------

def get_map_name(map_id)

mapinfo = load_data("Data/MapInfos.rvdata")

result = mapinfo[map_id].name

return result.split(/,/)[0].split(/_/)[0]

end

#--------------------------------------------------------------------------

#--------------------------------------------------------------------------

def update_help

text = $data_system.game_title

if @commands[self.index] != nil

text += ": " + @commands[self.index]

end

map_name = get_map_name($game_map.map_id)

text += " "

if map_name.include?"@"

text += "未知地域"

else

text += map_name

end

#-----------------------------------------------------------------------

@x,@y = $game_player.x,$game_player.y

text += " <#{@x},#{@y}>"

#-----------------------------------------------------------------------

@help_window.set_text(text)

end

end

#==============================================================================
[/pre]

也不知道自己会花多长时间忘记你,只希望我做了对的选择,你也一样。
梦石
0
星屑
55
在线时间
114 小时
注册时间
2012-3-26
回帖
46
发表于 2013-2-1 21:34:13 | 显示全部楼层
经测试原脚本没问题
157行的字母改了就会出现这问题
请检查脚本是否有奇怪的东西加了进去

评分

参与人数 1星屑 +100 收起 理由
hcm + 100 认可答案

查看全部评分

再起不能
回复

使用道具 举报

梦石
0
星屑
50
在线时间
105 小时
注册时间
2013-1-24
回帖
100
 楼主| 发表于 2013-2-1 22:30:08 | 显示全部楼层
极地小鸥 发表于 2013-2-1 21:34
经测试原脚本没问题
157行的字母改了就会出现这问题
请检查脚本是否有奇怪的东西加了进去 ...

谢谢谢谢。经过我傻瓜式排查发现是跟呼出对话框V6 那个脚本不兼容。现在换掉了对话框脚本问题没有了。谢谢你的回答~

也不知道自己会花多长时间忘记你,只希望我做了对的选择,你也一样。
回复

使用道具 举报

梦石
0
星屑
50
在线时间
35 小时
注册时间
2013-2-7
回帖
54
发表于 2013-2-8 01:36:19 | 显示全部楼层
这个小地图是直接可以使用的么O O 还是需要自己画小地图的?求原帖!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部