| 
 
| 赞 | 3 |  
| VIP | 35 |  
| 好人卡 | 0 |  
| 积分 | 3 |  
| 经验 | 10768 |  
| 最后登录 | 2022-8-10 |  
| 在线时间 | 185 小时 |  
 Lv2.观梦者 
	梦石0 星屑344 在线时间185 小时注册时间2007-9-2帖子168 | 
| 把事件名字設定爲這樣:复制代码#========================
class Scene_Map
  TANCE = 1 #动画ID
end
#========================
#Game_Event========================
class Game_Event
  attr_reader :event
end
#Game_Map========================
class Game_Map
  def tance
    for event in @events.values
      if event.event.name.split(/,/)[0] == "shine"
        $scene.shine.push event.event if $scene.is_a?(Scene_Map)
      end
    end
  end
end
class Game_Player < Game_Character
  alias tance_increase_steps increase_steps
  def increase_steps
    tance_increase_steps
    if $scene.is_a?(Scene_Map)
      $scene.check_tance
    end
  end
end
#Scene_Map========================
class Scene_Map
  attr_accessor :shine
  def initialize 
    @shine = []
  end
  alias tance_main main
  def main
    $game_map.tance
    @tance_wait = 0
    check_tance
    tance_main
  end
  alias tance_update update
  def update
    if @tance
          if Input.trigger?(Input::C)
          end
          if @tance_wait == 0
            #$game_player.animation_id = TANCE #靠近目标事件动作
            $game_map.events[@tance].animation_id = TANCE
            @tance_wait = 60
          else
            @tance_wait -= 1
          end
          if Input.trigger?(Input::C)
            $game_map.events[@tance].start
            @tance = nil
          end
        #=================================================
    end
    tance_update
  end
  def check_tance
    for event in @shine
      if (($game_player.x - event.x) ** 2 + ($game_player.y - event.y) ** 2) <= event.name.split(/,/)[1].to_i ** 2
        @tance = event.id
      else
        @tance = false
      end
    end
  end
end
 
 就是根據角色名字是否含有shine這個字符串來判斷事件類型,再根據 , 號後的第一個數字來判斷有效范圍。
 | 
 |