Project1

标题: 坐标类 [打印本页]

作者: taroxd    时间: 2015-2-7 08:10
标题: 坐标类
RUBY 代码复制
  1. #----------------------------------------------------------------------------
  2. # ● 该类的作用是表示一个地图上的点的坐标
  3. #    可以伪装成 Game_Character 的对象传给一些接受 character 参数的方法。
  4. #----------------------------------------------------------------------------
  5.  
  6. module Taroxd
  7.   Point = Struct.new(:x, :y) do
  8.  
  9.     alias_method :real_x, :x
  10.     alias_method :real_y, :y
  11.  
  12.     def moveto(x, y)
  13.       self.x = x
  14.       self.y = y
  15.     end
  16.  
  17.     def pos?(x2, y2)
  18.       x == x2 && y == y2
  19.     end
  20.  
  21.     def screen_x
  22.       $game_map.adjust_x(x) * 32 + 16
  23.     end
  24.  
  25.     def screen_y
  26.       $game_map.adjust_y(y) * 32 + 32
  27.     end
  28.   end
  29. end





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1