查看: 2268|回复: 0

坐标类

[复制链接]

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2015-2-7 08:10:08 | 显示全部楼层 |阅读模式

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

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

×
[pre lang="ruby"]

#----------------------------------------------------------------------------
# ● 该类的作用是表示一个地图上的点的坐标
#    可以伪装成 Game_Character 的对象传给一些接受 character 参数的方法。
#----------------------------------------------------------------------------

module Taroxd
  Point = Struct.new(:x, :y) do

    alias_method :real_x, :x
    alias_method :real_y, :y

    def moveto(x, y)
      self.x = x
      self.y = y
    end

    def pos?(x2, y2)
      x == x2 && y == y2
    end

    def screen_x
      $game_map.adjust_x(x) * 32 + 16
    end

    def screen_y
      $game_map.adjust_y(y) * 32 + 32
    end
  end
end
[/pre]

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

在本发帖返回顶部