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

Project1

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

[已经解决] 像素化移动脚本提示出错

[复制链接]

Lv3.寻梦者

梦石
0
星屑
4102
在线时间
766 小时
注册时间
2015-6-27
帖子
80

开拓者

跳转到指定楼层
1
发表于 2017-11-18 13:25:10 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x

出错的提示如图

这个像素化移动脚本是我从图书馆那里下载的,我直接从范例复制这个脚本到我的游戏里,不知道为什么点开始游戏就报错。。

我把我游戏里自己加的几个脚本都按顺序复制到范例里,结果没有报错,所以应该不是脚本冲突,但是到我的游戏里打开标题画面之后点开始游戏就报错了……
哪位大神能告诉我哪里出错了吗。。我对xp的脚本不是很熟悉。。

这是像素化移动的脚本:

  1. class Game_Temp
  2.   attr_accessor :rgss_move, :dir_4
  3.   #alias rgss_initialize_xxxxxxxxx initialize  默认值???
  4.   #def initialize
  5.   #  rgss_initialize_xxxxxxxxx
  6.   #  @rgss_move = false
  7.   #  @dir_4 = false
  8.   #end
  9. end
  10. class Game_Event < Game_Character
  11.   attr_reader :touch_4
  12.   alias rgss_refresh refresh
  13.   def refresh
  14.     rgss_refresh
  15.     @touch_4 = nil
  16.     for list in @page.list
  17.       if list.code == 108 or list.code == 408
  18.         if list.parameters[0] =~ /禁止斜触发/
  19.           @touch_4 = true
  20.           break
  21.         end
  22.       end
  23.     end
  24.   end
  25. end
  26. class Game_Player < Game_Character
  27.   def x(f=nil)
  28.     return !f ? @x.to_i : @x
  29.   end
  30.   def y(f=nil)
  31.     return !f ? @y.to_i : @y
  32.   end
  33.   def to_i
  34.     @x = @x.to_i if @x.is_a?(Float)
  35.     @y = @y.to_i if @y.is_a?(Float)
  36.   end
  37.   def player_passable?(dir = @direction, px = @x, py = @y)
  38.     case dir
  39.     when 8
  40.       (py - 0.5).to_i == py.to_i or (passable?(px.to_i, py.to_i, 8) and
  41.       passable?((px + 0.5).to_i, py.to_i, 8))
  42.     when 2
  43.       passable?(px.to_i, py.to_i, 2) and
  44.       passable?((px + 0.5).to_i, py.to_i, 2)
  45.     when 4
  46.       (px - 0.5).to_i == px.to_i or (passable?(px.to_i, py.to_i, 4) and
  47.       passable?(px.to_i, (py + 0.5).to_i, 4))
  48.     when 6
  49.       passable?(px.to_i, py.to_i, 6) and
  50.       passable?(px.to_i, (py + 0.5).to_i, 6)
  51.     when 1
  52.       (player_passable?(4) and player_passable?(2, @x - 0.5)) or
  53.       (player_passable?(2) and player_passable?(4, @x, @y + 0.5))
  54.     when 3
  55.       (player_passable?(6) and player_passable?(2, @x + 0.5)) or
  56.       (player_passable?(2) and player_passable?(6, @x, @y + 0.5))
  57.     when 7
  58.       (player_passable?(4) and player_passable?(8, @x - 0.5)) or
  59.       (player_passable?(8) and player_passable?(4, @x, @y - 0.5))
  60.     when 9
  61.       (player_passable?(6) and player_passable?(8, @x + 0.5)) or
  62.       (player_passable?(8) and player_passable?(6, @x, @y - 0.5))
  63.     end
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 接触事件启动判定
  67.   #--------------------------------------------------------------------------
  68.   def check_event_trigger_touch(x, y)
  69.     result = false
  70.     # 事件执行中的情况下
  71.     if $game_system.map_interpreter.running?
  72.       return result
  73.     end
  74.     # 全事件的循环
  75.     for event in $game_map.events.values
  76.       if event.touch_4
  77.         if (x - 0.5).to_i == x.to_i or
  78.           (y - 0.5).to_i == y.to_i
  79.           next
  80.         end
  81.       end
  82.       # 事件坐标与目标一致的情况下
  83.       if event.x == x.to_i and event.y == y.to_i and [1,2].include?(event.trigger)
  84.         # 跳跃中以外的情况下、启动判定是正面的事件
  85.         if not event.jumping? and not event.over_trigger?
  86.           event.start
  87.           result = true
  88.         end
  89.       end
  90.     end
  91.     return result
  92.   end
  93.   def player_check_event_trigger_touch(dir)
  94.     case dir
  95.     when 8
  96.       check_event_trigger_touch(@x, @y - 1)
  97.       if (@x + 0.5).to_i != @x.to_i
  98.         check_event_trigger_touch(@x + 1, @y - 1)
  99.       end
  100.     when 2
  101.       check_event_trigger_touch(@x, @y + 1)
  102.       if (@x + 0.5).to_i != @x.to_i
  103.         check_event_trigger_touch(@x + 1, @y + 1)
  104.       end
  105.     when 4
  106.       check_event_trigger_touch(@x - 1, @y)
  107.       if (@y + 0.5).to_i != @y.to_i
  108.         check_event_trigger_touch(@x - 1, @y + 1)
  109.       end
  110.     when 6
  111.       check_event_trigger_touch(@x + 1, @y)
  112.       if (@y + 0.5).to_i != @y.to_i
  113.         check_event_trigger_touch(@x + 1, @y + 1)
  114.       end
  115.     when 1
  116.       check_event_trigger_touch(@x - 1, @y + 1)
  117.       if (@x + 0.5).to_i != @x.to_i
  118.         check_event_trigger_touch(@x + 1 - 1, @y + 1)
  119.       end
  120.       check_event_trigger_touch(@x, @y + 1)
  121.       check_event_trigger_touch(@x - 1, @y)
  122.       if (@y + 0.5).to_i != @y.to_i
  123.         check_event_trigger_touch(@x - 1, @y + 1)
  124.       end
  125.     when 3
  126.       check_event_trigger_touch(@x + 1, @y + 1)
  127.       if (@x + 0.5).to_i != @x.to_i
  128.         check_event_trigger_touch(@x + 2, @y + 1)
  129.       end
  130.       check_event_trigger_touch(@x, @y + 1)
  131.       check_event_trigger_touch(@x + 1, @y)
  132.       if (@y + 0.5).to_i != @y.to_i
  133.         check_event_trigger_touch(@x + 1, @y + 1)
  134.       end
  135.     when 7
  136.       check_event_trigger_touch(@x - 1, @y - 1)
  137.       if (@x + 0.5).to_i != @x.to_i
  138.         check_event_trigger_touch(@x + 1 - 1, @y - 1)
  139.       end
  140.       check_event_trigger_touch(@x, @y - 1)
  141.       check_event_trigger_touch(@x - 1, @y)
  142.       if (@y + 0.5).to_i != @y.to_i
  143.         check_event_trigger_touch(@x - 1, @y - 1)
  144.       end
  145.     when 9
  146.       check_event_trigger_touch(@x + 1, @y - 1)
  147.       if (@x + 0.5).to_i != @x.to_i
  148.         check_event_trigger_touch(@x + 2, @y - 1)
  149.       end
  150.       check_event_trigger_touch(@x, @y - 1)
  151.       check_event_trigger_touch(@x + 1, @y)
  152.       if (@y + 0.5).to_i != @y.to_i
  153.         check_event_trigger_touch(@x + 1, @y - 1)
  154.       end
  155.     end
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● 同位置的事件启动判定
  159.   #--------------------------------------------------------------------------
  160.   def check_event_trigger_here(triggers)
  161.     result = false
  162.     # 事件执行中的情况下
  163.     if $game_system.map_interpreter.running?
  164.       return result
  165.     end
  166.     # 全部事件的循环
  167.     for event in $game_map.events.values
  168.       # 事件坐标与目标一致的情况下
  169.       if triggers.include?(event.trigger) and
  170.         ((event.x == @x.to_i and event.y == @y.to_i) or
  171.         (!event.touch_4 and event.x == (@x + 0.5).to_i and event.y == @y.to_i) or
  172.         (!event.touch_4 and event.x == @x.to_i and event.y == (@y + 0.5).to_i))
  173.         # 跳跃中以外的情况下、启动判定是同位置的事件
  174.         if not event.jumping? and event.over_trigger?
  175.           event.start
  176.           result = true
  177.         end
  178.       end
  179.     end
  180.     return result
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # ● 正面事件的启动判定
  184.   #--------------------------------------------------------------------------
  185.   def check_event_trigger_there(triggers)
  186.     result = false
  187.     # 事件执行中的情况下
  188.     if $game_system.map_interpreter.running?
  189.       return result
  190.     end
  191.     # 计算正面坐标
  192.     new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  193.     new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  194.     # 全部事件的循环
  195.     for event in $game_map.events.values
  196.       if event.touch_4
  197.         if (new_x - 0.5).to_i == new_x.to_i or
  198.           (new_y - 0.5).to_i == new_y.to_i
  199.           next
  200.         end
  201.       end
  202.       # 事件坐标与目标一致的情况下
  203.       if !player_passable? and triggers.include?(event.trigger) and
  204.          ((event.x == new_x.to_i and event.y == new_y.to_i) or
  205.           (!event.touch_4 and event.x == (new_x + 0.5).to_i and event.y == new_y.to_i) or
  206.           (!event.touch_4 and event.x == new_x.to_i and event.y == (new_y + 0.5).to_i))
  207.         # 跳跃中以外的情况下、启动判定是正面的事件
  208.         if not event.jumping? and not event.over_trigger?
  209.           event.start
  210.           result = true
  211.         end
  212.       end
  213.       next if event.touch_4
  214.       case @direction
  215.       when 2
  216.         if triggers.include?(event.trigger) and
  217.           ((event.x == @x.to_i - 1 and event.y == @y.to_i + 1) or
  218.           (event.x == @x.to_i + 1 and event.y == @y.to_i + 1))
  219.           # 跳跃中以外的情况下、启动判定是斜面的事件
  220.           if not event.jumping? and not event.over_trigger?
  221.             event.start
  222.             result = true
  223.           end
  224.         end
  225.       when 4
  226.         next if @x.to_i != (@x + 0.5).to_i
  227.         if triggers.include?(event.trigger) and
  228.           ((event.x == @x.to_i - 1 and event.y == @y.to_i - 1) or
  229.           (event.x == @x.to_i - 1 and event.y == @y.to_i + 1))
  230.           # 跳跃中以外的情况下、启动判定是斜面的事件
  231.           if not event.jumping? and not event.over_trigger?
  232.             event.start
  233.             result = true
  234.           end
  235.         end
  236.       when 6
  237.         next if @x.to_i != (@x + 0.5).to_i
  238.         if triggers.include?(event.trigger) and
  239.           ((event.x == @x.to_i + 1 and event.y == @y.to_i - 1) or
  240.           (event.x == @x.to_i + 1 and event.y == @y.to_i + 1))
  241.           # 跳跃中以外的情况下、启动判定是斜面的事件
  242.           if not event.jumping? and not event.over_trigger?
  243.             event.start
  244.             result = true
  245.           end
  246.         end
  247.       when 8
  248.         if triggers.include?(event.trigger) and
  249.           ((event.x == @x.to_i - 1 and event.y == @y.to_i - 1) or
  250.           (event.x == @x.to_i + 1 and event.y == @y.to_i - 1))
  251.           # 跳跃中以外的情况下、启动判定是斜面的事件
  252.           if not event.jumping? and not event.over_trigger?
  253.             event.start
  254.             result = true
  255.           end
  256.         end
  257.       end
  258.     end
  259.     # 找不到符合条件的事件的情况下
  260.     if result == false
  261.       # 正面的元件是柜台的情况下
  262.       if $game_map.counter?(new_x, new_y)
  263.         # 计算 1 元件里侧的坐标
  264.         new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  265.         new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  266.         # 全事件的循环
  267.         for event in $game_map.events.values
  268.           if event.touch_4
  269.             if (new_x - 0.5).to_i == new_x.to_i or
  270.               (new_y - 0.5).to_i == new_y.to_i
  271.               next
  272.             end
  273.           end
  274.           # 事件坐标与目标一致的情况下
  275.           if triggers.include?(event.trigger) and
  276.             ((event.x == new_x.to_i and event.y == new_y.to_i) or
  277.             (!event.touch_4 and event.x == (new_x + 0.5).to_i and event.y == new_y.to_i) or
  278.             (!event.touch_4 and event.x == new_x.to_i and event.y == (new_y + 0.5).to_i))
  279.             # 跳跃中以外的情况下、启动判定是正面的事件
  280.             if not event.jumping? and not event.over_trigger?
  281.               event.start
  282.               result = true
  283.             end
  284.           end
  285.         end
  286.       end
  287.     end
  288.     return result
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # ● 向上移动
  292.   #     turn_enabled : 本场地位置更改许可标志
  293.   #--------------------------------------------------------------------------
  294.   def move_up(turn_enabled = true)
  295.     if $game_temp.rgss_move then
  296.       to_i ; super ; return
  297.     end
  298.     # 面向上
  299.     if turn_enabled
  300.       turn_up
  301.     end
  302.     # 可以通行的情况下
  303.     if player_passable?(8)
  304.       # 面向上
  305.       turn_up
  306.       # 更新坐标
  307.       @y -= 0.5
  308.       # 歩数増加
  309.       increase_steps
  310.     # 不能通行的情况下
  311.     else
  312.       # 接触事件的启动判定
  313.       player_check_event_trigger_touch(8)
  314.     end
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ● 向下移动
  318.   #     turn_enabled : 本场地位置更改许可标志
  319.   #--------------------------------------------------------------------------
  320.   def move_down(turn_enabled = true)
  321.     if $game_temp.rgss_move then
  322.       to_i ; super ; return
  323.     end
  324.     # 面向下
  325.     if turn_enabled
  326.       turn_down
  327.     end
  328.     # 可以通行的场合
  329.     if player_passable?(2)
  330.       # 面向下
  331.       turn_down
  332.       # 更新坐标
  333.       @y += 0.5
  334.       # 增加步数
  335.       increase_steps
  336.     # 不能通行的情况下
  337.     else
  338.       # 接触事件的启动判定
  339.       player_check_event_trigger_touch(2)
  340.     end
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● 向左移动
  344.   #     turn_enabled : 本场地位置更改许可标志
  345.   #--------------------------------------------------------------------------
  346.   def move_left(turn_enabled = true)
  347.     if $game_temp.rgss_move then
  348.       to_i ; super ; return
  349.     end
  350.     # 面向左
  351.     if turn_enabled
  352.       turn_left
  353.     end
  354.     # 可以通行的情况下
  355.     if player_passable?(4)
  356.       # 面向左
  357.       turn_left
  358.       # 更新坐标
  359.       @x -= 0.5
  360.       # 增加步数
  361.       increase_steps
  362.     # 不能通行的情况下
  363.     else
  364.       # 接触事件的启动判定
  365.       player_check_event_trigger_touch(4)
  366.     end
  367.   end
  368.   #--------------------------------------------------------------------------
  369.   # ● 向右移动
  370.   #     turn_enabled : 本场地位置更改许可标志
  371.   #--------------------------------------------------------------------------
  372.   def move_right(turn_enabled = true)
  373.     if $game_temp.rgss_move then
  374.       to_i ; super ; return
  375.     end
  376.     # 面向右
  377.     if turn_enabled
  378.       turn_right
  379.     end
  380.     # 可以通行的场合
  381.     if player_passable?(6)
  382.       # 面向右
  383.       turn_right
  384.       # 更新坐标
  385.       @x += 0.5
  386.       # 增加步数
  387.       increase_steps
  388.     # 不能通行的情况下
  389.     else
  390.       # 接触事件的启动判定
  391.       player_check_event_trigger_touch(6)
  392.     end
  393.   end
  394.   #--------------------------------------------------------------------------
  395.   # ● 向左下移动
  396.   #--------------------------------------------------------------------------
  397.   def move_lower_left
  398.     if $game_temp.rgss_move then
  399.       to_i ; super ; return
  400.     end
  401.     # 没有固定面向的场合
  402.     unless @direction_fix
  403.       # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  404.       @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  405.     end
  406.     # 下→左、左→下 的通道可以通行的情况下
  407.     if player_passable?(1)
  408.       # 更新坐标
  409.       @x -= 0.5
  410.       @y += 0.5
  411.       # 增加步数
  412.       increase_steps
  413.     else
  414.       # 接触事件的启动判定
  415.       player_check_event_trigger_touch(1)
  416.     end
  417.   end
  418.   #--------------------------------------------------------------------------
  419.   # ● 向右下移动
  420.   #--------------------------------------------------------------------------
  421.   def move_lower_right
  422.     if $game_temp.rgss_move then
  423.       to_i ; super ; return
  424.     end
  425.     # 没有固定面向的场合
  426.     unless @direction_fix
  427.       # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  428.       @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  429.     end
  430.     # 下→右、右→下 的通道可以通行的情况下
  431.     if player_passable?(3)
  432.       # 更新坐标
  433.       @x += 0.5
  434.       @y += 0.5
  435.       # 增加步数
  436.       increase_steps
  437.     else
  438.       # 接触事件的启动判定
  439.       player_check_event_trigger_touch(3)
  440.     end
  441.   end
  442.   #--------------------------------------------------------------------------
  443.   # ● 向左上移动
  444.   #--------------------------------------------------------------------------
  445.   def move_upper_left
  446.     if $game_temp.rgss_move then
  447.       to_i ; super ; return
  448.     end
  449.     # 没有固定面向的场合
  450.     unless @direction_fix
  451.       # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  452.       @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  453.     end
  454.     # 上→左、左→上 的通道可以通行的情况下
  455.     if player_passable?(7)
  456.       # 更新坐标
  457.       @x -= 0.5
  458.       @y -= 0.5
  459.       # 增加步数
  460.       increase_steps
  461.     else
  462.       # 接触事件的启动判定
  463.       player_check_event_trigger_touch(7)
  464.     end
  465.   end
  466.   #--------------------------------------------------------------------------
  467.   # ● 向右上移动
  468.   #--------------------------------------------------------------------------
  469.   def move_upper_right
  470.     if $game_temp.rgss_move then
  471.       to_i ; super ; return
  472.     end
  473.     # 没有固定面向的场合
  474.     unless @direction_fix
  475.       # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  476.       @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  477.     end
  478.     # 上→右、右→上 的通道可以通行的情况下
  479.     if player_passable?(9)
  480.       # 更新坐标
  481.       @x += 0.5
  482.       @y -= 0.5
  483.       # 增加步数
  484.       increase_steps
  485.     else
  486.       # 接触事件的启动判定
  487.       player_check_event_trigger_touch(9)
  488.     end
  489.   end
  490.   #--------------------------------------------------------------------------
  491.   # ● 画面更新
  492.   #--------------------------------------------------------------------------
  493.   alias rgss_update update
  494.   def update
  495.     if $game_temp.dir_4
  496.       rgss_update
  497.       return
  498.     end
  499.     # 本地变量记录移动信息
  500.     last_moving = moving?
  501.     # 移动中、事件执行中、强制移动路线中、
  502.     # 信息窗口一个也不显示的时候
  503.     unless moving? or $game_system.map_interpreter.running? or
  504.            @move_route_forcing or $game_temp.message_window_showing
  505.       # 如果方向键被按下、主角就朝那个方向移动
  506.       case Input.dir8
  507.       when 1
  508.         move_lower_left
  509.       when 2
  510.         move_down
  511.       when 3
  512.         move_lower_right
  513.       when 4
  514.         move_left
  515.       when 6
  516.         move_right
  517.       when 7
  518.         move_upper_left
  519.       when 8
  520.         move_up
  521.       when 9
  522.         move_upper_right
  523.       end
  524.     end
  525.     # 本地变量记忆坐标
  526.     last_real_x = @real_x
  527.     last_real_y = @real_y
  528.     super
  529.     # 角色向下移动、画面上的位置在中央下方的情况下
  530.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  531.       # 画面向下卷动
  532.       $game_map.scroll_down(@real_y - last_real_y)
  533.     end
  534.     # 角色向左移动、画面上的位置在中央左方的情况下
  535.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  536.       # 画面向左卷动
  537.       $game_map.scroll_left(last_real_x - @real_x)
  538.     end
  539.     # 角色向右移动、画面上的位置在中央右方的情况下
  540.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  541.       # 画面向右卷动
  542.       $game_map.scroll_right(@real_x - last_real_x)
  543.     end
  544.     # 角色向上移动、画面上的位置在中央上方的情况下
  545.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  546.       # 画面向上卷动
  547.       $game_map.scroll_up(last_real_y - @real_y)
  548.     end
  549.     # 不在移动中的情况下
  550.     unless moving?
  551.       # 上次主角移动中的情况
  552.       if last_moving
  553.         # 与同位置的事件接触就判定为事件启动
  554.         result = check_event_trigger_here([1,2])
  555.         # 没有可以启动的事件的情况下
  556.         if result == false
  557.           # 调试模式为 ON 并且按下 CTRL 键的情况下除外
  558.           unless $DEBUG and Input.press?(Input::CTRL)
  559.             # 遇敌计数下降
  560.             if @encounter_count > 0
  561.               @encounter_count -= 1
  562.             end
  563.           end
  564.         end
  565.       end
  566.       # 按下 C 键的情况下
  567.       if Input.trigger?(Input::C)
  568.         # 判定为同位置以及正面的事件启动
  569.         check_event_trigger_here([0])
  570.         check_event_trigger_there([0,1,2])
  571.       end
  572.     end
  573.   end
  574. end
复制代码

鸽子本鸽

Lv5.捕梦者

梦石
0
星屑
36124
在线时间
10712 小时
注册时间
2009-3-15
帖子
4806
2
发表于 2017-11-18 13:39:52 | 只看该作者
重新开始遊戏试试?

点评

这应该算是解决了,非常感谢你啊!  发表于 2017-11-18 14:15
我试了试 很奇葩 似乎只有在角色初始在ID为1的那个地图才会这样 到别的地图初始就没事了  发表于 2017-11-18 13:47
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-21 16:28

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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