设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1141|回复: 1
打印 上一主题 下一主题

[已经过期] 这个是怎么回事?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
29 小时
注册时间
2012-2-1
帖子
12
跳转到指定楼层
1
发表于 2012-2-6 17:31:26 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
[attachimg]97867[/attachim
测试游戏的时候遇到这个情况,请问怎么
  1. #==============================================================================
  2. # ■ Game_Map
  3. #------------------------------------------------------------------------------
  4. #  处理地图的类。包含卷动以及可以通行的判断功能。
  5. # 本类的实例请参考 $game_map 。
  6. #==============================================================================

  7. class Game_Map
  8.   #--------------------------------------------------------------------------
  9.   # ● 定义实例变量
  10.   #--------------------------------------------------------------------------
  11.   attr_reader   :screen                   # 地图画面状态
  12.   attr_reader   :interpreter              # 地图事件用解释器
  13.   attr_reader   :display_x                # 显示 X 坐标 * 256
  14.   attr_reader   :display_y                # 显示 Y 坐标 * 256
  15.   attr_reader   :parallax_name            # 远景文件名
  16.   attr_reader   :passages                 # 通行表
  17.   attr_reader   :events                   # 事件
  18.   attr_reader   :vehicles                 # 交通工具
  19.   attr_accessor :need_refresh             # 请求刷新标志
  20.   #--------------------------------------------------------------------------
  21.   # ● 初始化对象
  22.   #--------------------------------------------------------------------------
  23.   def initialize
  24.     @screen = Game_Screen.new
  25.     @interpreter = Game_Interpreter.new(0, true)
  26.     @map_id = 0
  27.     @display_x = 0
  28.     @display_y = 0
  29.     create_vehicles
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 设置
  33.   #     map_id : 地图 ID
  34.   #--------------------------------------------------------------------------
  35.   def setup(map_id)
  36.     @map_id = map_id
  37.     @map = load_data(sprintf("Data/Map%03d.rvdata", @map_id))
  38.     @display_x = 0
  39.     @display_y = 0
  40.     @passages = $data_system.passages
  41.     referesh_vehicles
  42.     setup_events
  43.     setup_scroll
  44.     setup_parallax
  45.     @need_refresh = false
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● 生成交通工具
  49.   #--------------------------------------------------------------------------
  50.   def create_vehicles
  51.     @vehicles = []
  52.     @vehicles[0] = Game_Vehicle.new(0)    # 小型船
  53.     @vehicles[1] = Game_Vehicle.new(1)    # 大型船
  54.     @vehicles[2] = Game_Vehicle.new(2)    # 飞行船
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # ● 刷新交通工具
  58.   #--------------------------------------------------------------------------
  59.   def referesh_vehicles
  60.     for vehicle in @vehicles
  61.       vehicle.refresh
  62.     end
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # ● 获取小型船
  66.   #--------------------------------------------------------------------------
  67.   def boat
  68.     return @vehicles[0]
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● 获取大型船
  72.   #--------------------------------------------------------------------------
  73.   def ship
  74.     return @vehicles[1]
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ● 获取飞行船
  78.   #--------------------------------------------------------------------------
  79.   def airship
  80.     return @vehicles[2]
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # ● 设置事件
  84.   #--------------------------------------------------------------------------
  85.   def setup_events
  86.     @events = {}          # 地图事件
  87.     for i in @map.events.keys
  88.       @events[i] = Game_Event.new(@map_id, @map.events[i])
  89.     end
  90.     @common_events = {}   # 公共事件
  91.     for i in 1...$data_common_events.size
  92.       @common_events[i] = Game_CommonEvent.new(i)
  93.     end
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ● 滚动设置
  97.   #--------------------------------------------------------------------------
  98.   def setup_scroll
  99.     @scroll_direction = 2
  100.     @scroll_rest = 0
  101.     @scroll_speed = 4
  102.     @margin_x = (width - 17) * 256 / 2      # 画面不显示部分横向 / 2
  103.     @margin_y = (height - 13) * 256 / 2     # 画面不显示部分纵向 / 2
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● 设置远景
  107.   #--------------------------------------------------------------------------
  108.   def setup_parallax
  109.     @parallax_name = @map.parallax_name
  110.     @parallax_loop_x = @map.parallax_loop_x
  111.     @parallax_loop_y = @map.parallax_loop_y
  112.     @parallax_sx = @map.parallax_sx
  113.     @parallax_sy = @map.parallax_sy
  114.     @parallax_x = 0
  115.     @parallax_y = 0
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 设置显示位置
  119.   #     x : 新显示的 X 坐标 (*256)
  120.   #     y : 新显示的 Y 坐标 (*256)
  121.   #--------------------------------------------------------------------------
  122.   def set_display_pos(x, y)
  123.     @display_x = (x + @map.width * 256) % (@map.width * 256)
  124.     @display_y = (y + @map.height * 256) % (@map.height * 256)
  125.     @parallax_x = x
  126.     @parallax_y = y
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # ● 计算显示远景的 X 坐标
  130.   #     bitmap : 远景位图
  131.   #--------------------------------------------------------------------------
  132.   def calc_parallax_x(bitmap)
  133.     if bitmap == nil
  134.       return 0
  135.     elsif @parallax_loop_x
  136.       return @parallax_x / 16
  137.     elsif loop_horizontal?
  138.       return 0
  139.     else
  140.       w1 = bitmap.width - 544
  141.       w2 = @map.width * 32 - 544
  142.       if w1 <= 0 or w2 <= 0
  143.         return 0
  144.       else
  145.         return @parallax_x * w1 / w2 / 8
  146.       end
  147.     end
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # ● 计算显示远景的 Y 坐标
  151.   #     bitmap : 远景位图
  152.   #--------------------------------------------------------------------------
  153.   def calc_parallax_y(bitmap)
  154.     if bitmap == nil
  155.       return 0
  156.     elsif @parallax_loop_y
  157.       return @parallax_y / 16
  158.     elsif loop_vertical?
  159.       return 0
  160.     else
  161.       h1 = bitmap.height - 416
  162.       h2 = @map.height * 32 - 416
  163.       if h1 <= 0 or h2 <= 0
  164.         return 0
  165.       else
  166.         return @parallax_y * h1 / h2 / 8
  167.       end
  168.     end
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # ● 获取地图 ID
  172.   #--------------------------------------------------------------------------
  173.   def map_id
  174.     return @map_id
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # ● 获取宽
  178.   #--------------------------------------------------------------------------
  179.   def width
  180.     return @map.width
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # ● 获取高
  184.   #--------------------------------------------------------------------------
  185.   def height
  186.     return @map.height
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● 横向循环吗?
  190.   #--------------------------------------------------------------------------
  191.   def loop_horizontal?
  192.     return (@map.scroll_type == 2 or @map.scroll_type == 3)
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ● 纵向循环吗?
  196.   #--------------------------------------------------------------------------
  197.   def loop_vertical?
  198.     return (@map.scroll_type == 1 or @map.scroll_type == 3)
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● 获取禁止跑动
  202.   #--------------------------------------------------------------------------
  203.   def disable_dash?
  204.     return @map.disable_dashing
  205.   end
  206.   #--------------------------------------------------------------------------
  207.   # ● 获取遇敌列表
  208.   #--------------------------------------------------------------------------
  209.   def encounter_list
  210.     return @map.encounter_list
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # ● 获取遇敌步数
  214.   #--------------------------------------------------------------------------
  215.   def encounter_step
  216.     return @map.encounter_step
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ● 获取地图数据
  220.   #--------------------------------------------------------------------------
  221.   def data
  222.     return @map.data
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● 计算显示坐标 X 差
  226.   #     x : X 坐标
  227.   #--------------------------------------------------------------------------
  228.   def adjust_x(x)
  229.     if loop_horizontal? and x < @display_x - @margin_x
  230.       return x - @display_x + @map.width * 256
  231.     else
  232.       return x - @display_x
  233.     end
  234.   end
  235.   #--------------------------------------------------------------------------
  236.   # ● 计算显示坐标 I 差
  237.   #     y : Y 坐标
  238.   #--------------------------------------------------------------------------
  239.   def adjust_y(y)
  240.     if loop_vertical? and y < @display_y - @margin_y
  241.       return y - @display_y + @map.height * 256
  242.     else
  243.       return y - @display_y
  244.     end
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   # ● 计算循环修正后的 X 坐标
  248.   #     x : X 坐标
  249.   #--------------------------------------------------------------------------
  250.   def round_x(x)
  251.     if loop_horizontal?
  252.       return (x + width) % width
  253.     else
  254.       return x
  255.     end
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ● 计算循环修正后的 Y 坐标
  259.   #     y : Y 坐标
  260.   #--------------------------------------------------------------------------
  261.   def round_y(y)
  262.     if loop_vertical?
  263.       return (y + height) % height
  264.     else
  265.       return y
  266.     end
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ● 计算特定方向的一格 X 坐标
  270.   #     x         : X 坐标
  271.   #     direction : 方向 (2,4,6,8)
  272.   #--------------------------------------------------------------------------
  273.   def x_with_direction(x, direction)
  274.     return round_x(x + (direction == 6 ? 1 : direction == 4 ? -1 : 0))
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # ● 计算特定方向的一格 Y 坐标
  278.   #     y         : Y 坐标
  279.   #     direction : 方向 (2,4,6,8)
  280.   #--------------------------------------------------------------------------
  281.   def y_with_direction(y, direction)
  282.     return round_y(y + (direction == 2 ? 1 : direction == 8 ? -1 : 0))
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # ● 获取指定坐标存在的事件列表
  286.   #     x : X 坐标
  287.   #     y : Y 坐标
  288.   #--------------------------------------------------------------------------
  289.   def events_xy(x, y)
  290.     result = []
  291.     for event in $game_map.events.values
  292.       result.push(event) if event.pos?(x, y)
  293.     end
  294.     return result
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ● 自动切换 BGM / BGS
  298.   #--------------------------------------------------------------------------
  299.   def autoplay
  300.     @map.bgm.play if @map.autoplay_bgm
  301.     @map.bgs.play if @map.autoplay_bgs
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # ● 刷新
  305.   #--------------------------------------------------------------------------
  306.   def refresh
  307.     if @map_id > 0
  308.       for event in @events.values
  309.         event.refresh
  310.       end
  311.       for common_event in @common_events.values
  312.         common_event.refresh
  313.       end
  314.     end
  315.     @need_refresh = false
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # ● 向下滚动
  319.   #     distance : 滚动距离
  320.   #--------------------------------------------------------------------------
  321.   def scroll_down(distance)
  322.     if loop_vertical?
  323.       @display_y += distance
  324.       @display_y %= @map.height * 256
  325.       @parallax_y += distance
  326.     else
  327.       last_y = @display_y
  328.       @display_y = [@display_y + distance, (height - 13) * 256].min
  329.       @parallax_y += @display_y - last_y
  330.     end
  331.   end
  332.   #--------------------------------------------------------------------------
  333.   # ● 向左滚动
  334.   #     distance : 滚动距离
  335.   #--------------------------------------------------------------------------
  336.   def scroll_left(distance)
  337.     if loop_horizontal?
  338.       @display_x += @map.width * 256 - distance
  339.       @display_x %= @map.width * 256
  340.       @parallax_x -= distance
  341.     else
  342.       last_x = @display_x
  343.       @display_x = [@display_x - distance, 0].max
  344.       @parallax_x += @display_x - last_x
  345.     end
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ● 向右滚动
  349.   #     distance : 滚动距离
  350.   #--------------------------------------------------------------------------
  351.   def scroll_right(distance)
  352.     if loop_horizontal?
  353.       @display_x += distance
  354.       @display_x %= @map.width * 256
  355.       @parallax_x += distance
  356.     else
  357.       last_x = @display_x
  358.       @display_x = [@display_x + distance, (width - 17) * 256].min
  359.       @parallax_x += @display_x - last_x
  360.     end
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # ● 向上滚动
  364.   #     distance : 滚动距离
  365.   #--------------------------------------------------------------------------
  366.   def scroll_up(distance)
  367.     if loop_vertical?
  368.       @display_y += @map.height * 256 - distance
  369.       @display_y %= @map.height * 256
  370.       @parallax_y -= distance
  371.     else
  372.       last_y = @display_y
  373.       @display_y = [@display_y - distance, 0].max
  374.       @parallax_y += @display_y - last_y
  375.     end
  376.   end
  377.   #--------------------------------------------------------------------------
  378.   # ● 判断坐标有效性
  379.   #     x : X 坐标
  380.   #     y : Y 坐标
  381.   #--------------------------------------------------------------------------
  382.   def valid?(x, y)
  383.     return (x >= 0 and x < width and y >= 0 and y < height)
  384.   end
  385.   #--------------------------------------------------------------------------
  386.   # ● 判断是否可以通行
  387.   #     x    : X 坐标
  388.   #     y    : Y 坐标
  389.   #     flag : 不能通行的点 (一般情况下为 0x01、可以在交通工具的情况下被更改)
  390.   #--------------------------------------------------------------------------
  391.   def passable?(x, y, flag = 0x01)
  392.     for event in events_xy(x, y)            # 调用坐标一致的事件
  393.       next if event.tile_id == 0            # 没有元件图片
  394.       next if event.priority_type > 0       # 不是"在普通角色下"
  395.       next if event.through                 # 直接通过状态
  396.       pass = @passages[event.tile_id]       # 获取通行属性
  397.       next if pass & 0x10 == 0x10           # [☆] : 不受通行影响
  398.       return true if pass & flag == 0x00    # [○] : 可以通行
  399.       return false if pass & flag == flag   # [×] : 不可以通行
  400.     end
  401.     for i in [2, 1, 0]                      # 调用图层顺序
  402.       tile_id = @map.data[x, y, i]          # 获取元件 ID
  403.       return false if tile_id == nil        # 获取元件 ID 失败 : 不可以通行
  404.       pass = @passages[tile_id]             # 获取通行属性
  405.       next if pass & 0x10 == 0x10           # [☆] : 不受通行影响
  406.       return true if pass & flag == 0x00    # [○] : 可以通行
  407.       return false if pass & flag == flag   # [×] : 不可以通行
  408.     end
  409.     return false                            # 不可以通行
  410.   end
  411.   #--------------------------------------------------------------------------
  412.   # ● 判断小型船可以通过
  413.   #     x : X 坐标
  414.   #     y : Y 坐标
  415.   #--------------------------------------------------------------------------
  416.   def boat_passable?(x, y)
  417.     return passable?(x, y, 0x02)
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # ● 判断大型船可以通过
  421.   #     x : X 坐标
  422.   #     y : Y 坐标
  423.   #--------------------------------------------------------------------------
  424.   def ship_passable?(x, y)
  425.     return passable?(x, y, 0x04)
  426.   end
  427.   #--------------------------------------------------------------------------
  428.   # ● 判断飞行船可以着陆
  429.   #     x : X 坐标
  430.   #     y : Y 坐标
  431.   #--------------------------------------------------------------------------
  432.   def airship_land_ok?(x, y)
  433.     return passable?(x, y, 0x08)
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   # ● 判断繁茂
  437.   #     x : X 坐标
  438.   #     y : Y 坐标
  439.   #--------------------------------------------------------------------------
  440.   def bush?(x, y)
  441.     return false unless valid?(x, y)
  442.     return @passages[@map.data[x, y, 1]] & 0x40 == 0x40
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   # ● 判断抵消
  446.   #     x : X 坐标
  447.   #     y : Y 坐标
  448.   #--------------------------------------------------------------------------
  449.   def counter?(x, y)
  450.     return false unless valid?(x, y)
  451.     return @passages[@map.data[x, y, 0]] & 0x80 == 0x80
  452.   end
  453.   #--------------------------------------------------------------------------
  454.   # ● 开始滚动
  455.   #     direction : 滚动方向
  456.   #     distance  : 滚动距离
  457.   #     speed     : 滚动速度
  458.   #--------------------------------------------------------------------------
  459.   def start_scroll(direction, distance, speed)
  460.     @scroll_direction = direction
  461.     @scroll_rest = distance * 256
  462.     @scroll_speed = speed
  463.   end
  464.   #--------------------------------------------------------------------------
  465.   # ● 判断是否在滚动中
  466.   #--------------------------------------------------------------------------
  467.   def scrolling?
  468.     return @scroll_rest > 0
  469.   end
  470.   #--------------------------------------------------------------------------
  471.   # ● 刷新画面
  472.   #--------------------------------------------------------------------------
  473.   def update
  474.     refresh if $game_map.need_refresh
  475.     update_scroll
  476.     update_events
  477.     update_vehicles
  478.     update_parallax
  479.     @screen.update
  480.   end
  481.   #--------------------------------------------------------------------------
  482.   # ● 刷新滚动
  483.   #--------------------------------------------------------------------------
  484.   def update_scroll
  485.     if @scroll_rest > 0                 # 在滚动的情况下
  486.       distance = 2 ** @scroll_speed     # 变换地图坐标系
  487.       case @scroll_direction
  488.       when 2  # 下
  489.         scroll_down(distance)
  490.       when 4  # 左
  491.         scroll_left(distance)
  492.       when 6  # 右
  493.         scroll_right(distance)
  494.       when 8  # 上
  495.         scroll_up(distance)
  496.       end
  497.       @scroll_rest -= distance          # 减去已滚动的距离
  498.     end
  499.   end
  500.   #--------------------------------------------------------------------------
  501.   # ● 更新事件
  502.   #--------------------------------------------------------------------------
  503.   def update_events
  504.     for event in @events.values
  505.       event.update
  506.     end
  507.     for common_event in @common_events.values
  508.       common_event.update
  509.     end
  510.   end
  511.   #--------------------------------------------------------------------------
  512.   # ● 更新交通工具
  513.   #--------------------------------------------------------------------------
  514.   def update_vehicles
  515.     for vehicle in @vehicles
  516.       vehicle.update
  517.     end
  518.   end
  519.   #--------------------------------------------------------------------------
  520.   # ● 更新远景
  521.   #--------------------------------------------------------------------------
  522.   def update_parallax
  523.     @parallax_x += @parallax_sx * 4 if @parallax_loop_x
  524.     @parallax_y += @parallax_sy * 4 if @parallax_loop_y
  525.   end
  526. end
复制代码
办?
额,麻烦看看怎么回事,有什么事吗?

啊啊飞.png (5.68 KB, 下载次数: 13)

啊啊飞.png

Lv1.梦旅人

王牌

梦石
0
星屑
50
在线时间
188 小时
注册时间
2011-5-16
帖子
224
2
发表于 2012-2-18 10:01:06 | 只看该作者
难道是脚本冲突?你用了其他什么脚本?
      
回复

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-30 18:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表