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

Project1

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

[已经解决] XP移植当前坐标跟踪显示脚本,为啥飞船的坐标不更新呢?

[复制链接]

Lv2.观梦者

梦石
0
星屑
432
在线时间
4175 小时
注册时间
2010-6-26
帖子
6474
跳转到指定楼层
1
发表于 2012-3-27 05:01:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
先上脚本

  1. #==========================================================================
  2. # 本脚本来自www.66rpg.com,用于任何游戏请保留此信息。别以为加密就可以del哦
  3. #==========================================================================
  4. #==========================================================================
  5. # 本脚本来自www.66rpg.com,用于任何游戏请保留此信息。别以为加密就可以del哦
  6. # 鉴定为古老脚本,作者不明。 By 絮语 2011.2
  7. # 改订 By 絮语 2011.4
  8. #==========================================================================
  9. XY_SWITCH = 28 # 当3号开关关闭,本脚本才开始工作。
  10. #BACK_PNG = RPG::Cache.system('游戏边框右下.png') #背景

  11. #==============================================================================
  12. # ■ Window_XY
  13. #------------------------------------------------------------------------------
  14. #  显示坐标的窗口。
  15. #==============================================================================
  16. class Window_xy < Window_Base#注意前面那个window_xy是文件名   
  17.   #--------------------------------------------------------------------------
  18.   # ● 初始化窗口
  19.   #--------------------------------------------------------------------------
  20.   def initialize
  21.     super(0, Graphics.height - 99, 820, 696)#最后面那个数字是宽要显示多个需要改大,前面一个是长~
  22.     self.contents = Bitmap.new(width - 32, height - 32)
  23.     self.back_opacity = 255  # 这个是背景透明
  24.     self.opacity = 255       # 这个是边框和背景都透明
  25.     self.contents_opacity = 255       # 这个是内容透明
  26.     self.visible = false
  27.     self.z = 1000
  28.     refresh
  29.     @x = $game_player.x
  30.     @y = $game_player.y
  31.     @id = $game_map.map_id
  32.   end
  33.   def main_color
  34.     return Color.new(-210, -210, -210, 255)
  35.   end
  36.   def main2_color
  37.     return Color.new(-180, -170, -170, 255)
  38.   end
  39.   def else_color
  40.     return Color.new(-140, -140, -140, 255)
  41.   end
  42. #--------------------------------------------------------------------------
  43. # ● 刷新
  44. #--------------------------------------------------------------------------
  45.   def refresh   
  46.     #确定开关是否打开,可以自己改变开关
  47.     unless $game_switches[XY_SWITCH]
  48.       @x = $game_player.x #获取角色X坐标
  49.       @y = $game_player.y #获取角色Y坐标
  50.       @id = $game_map.map_id  #获取地图编号
  51.       
  52.       @airship_x = Game_Vehicle.new(:airship).x
  53.       @airship_y = Game_Vehicle.new(:airship).y
  54.       
  55.       self.contents.clear #清除以前的东西
  56.       if @back != nil
  57.         if @back.visible
  58.           @back.dispose
  59.         end
  60.    
  61.       end
  62.       $mapnames = load_data("Data/MapInfos.rvdata2") #读取地图名文件
  63.       map_name = $mapnames[@id].name #获得地图名
  64.       self.contents.font.size = 20
  65.       self.contents.font.color = main_color#颜色
  66.       self.contents.draw_text(0, 0, 160, 32, map_name)
  67.       self.contents.font.color = else_color
  68.       self.contents.draw_text(10, 32, 120, 32, "X:")#显示X这个字的位置,引号里面的内容随便改,比如"X坐标地址"
  69.       self.contents.font.color = main2_color
  70.       self.contents.draw_text(10, 32, 52, 32, @x.to_s,2)
  71.       self.contents.font.color = else_color#上面那个是X坐标的变量,可以自己更改变量名~
  72.       self.contents.draw_text(74, 32, 128, 32, "Y:")#显示Y这个字~
  73.       self.contents.font.color = main2_color
  74.       self.contents.draw_text(10, 32, 116, 32, @y.to_s,2)
  75.       #添加交通工具的坐标
  76.       self.contents.font.size = 20
  77.       self.contents.font.color = main_color#颜色
  78.       self.contents.draw_text(100, 00, 160, 32, "飞船位置",2)
  79.       self.contents.font.color = else_color
  80.       self.contents.draw_text(140, 32, 120, 32, "X:")#显示X这个字的位置,引号里面的内容随便改,比如"X坐标地址"
  81.       self.contents.font.color = main2_color
  82.       self.contents.draw_text(140, 32, 52, 32, @airship_x.to_s,2)
  83.       self.contents.font.color = else_color#上面那个是X坐标的变量,可以自己更改变量名~
  84.       self.contents.draw_text(204, 32, 128, 32, "Y:")#显示Y这个字~
  85.       self.contents.font.color = main2_color
  86.       self.contents.draw_text(140, 32, 116, 32, @airship_y.to_s,2)
  87.       
  88.     end
  89.   end
  90. #--------------------------------------------------------------------------
  91. # ● 判断文字刷新。节约内存用
  92. #--------------------------------------------------------------------------
  93.   def judge
  94.     return true if @x != $game_player.x
  95.     return true if @y != $game_player.y
  96.     return true if @id != $game_map.map_id
  97.     return true if @airship_x != Game_Vehicle.new(:airship).x
  98.     return true if @airship_y != Game_Vehicle.new(:airship).y
  99.     return false
  100.   end
  101. end
  102. ###########################################################################
  103. #                           下面的东西不需要掌握~                         #
  104. ###########################################################################

  105. class Scene_Map
  106.   alias xy_66rpg_main main
  107.   def main
  108.     @xy_window = Window_xy.new
  109.     #原来这里是设置坐标的啊,不过下面两个是内容
  110.     #@xy_window.x = 800 - 190
  111.     #@xy_window.y = 600 - 96
  112.     @xy_window.opacity = 0
  113.     xy_66rpg_main
  114.     @xy_window.dispose
  115.   end
  116. #--------------------------------------------------------------------------
  117. # ● 刷新画面
  118. #--------------------------------------------------------------------------
  119.   alias xy_66rpg_update update
  120.   def update
  121.     xy_66rpg_update
  122.     unless $game_switches[XY_SWITCH]
  123.       @xy_window.visible = true
  124.       if @边框右下 != nil and @边框右下.visible
  125.           @边框右下.dispose
  126.         
  127.       end
  128.       if @边框左上 != nil and @边框左上.visible
  129.         @边框左上.dispose
  130.       end
  131.       @边框右下 = Sprite.new
  132.       @边框右下.x = 0 #- 256
  133.       @边框右下.y = 0
  134.       #@边框右下.bitmap = RPG::Cache.system('游戏边框.png')
  135.       @xy_window.refresh if @xy_window.judge
  136.     else
  137.       @xy_window.visible = false
  138.     end
  139.   end
  140. end
  141. #==========================================================================
  142. # 本脚本来自www.66rpg.com,用于任何游戏请保留此信息。别以为加密就可以del哦
  143. #==========================================================================
复制代码
这是我从XP移植过来的显示角色所在位置的脚本,

我想顺便添加交通工具坐标的显示功能,这样一来,就可以看到自己的交通工具在哪,在啥地方,

于是我先用飞船做实验,不过找不到合适的方法来显示飞船所在地图名称不说,搭乘飞船之后,飞船的坐标也不跟着更新!
潜水,专心忙活三次元工作了……

Lv2.观梦者

梦石
0
星屑
465
在线时间
915 小时
注册时间
2011-5-11
帖子
438
2
发表于 2012-3-27 09:17:31 | 只看该作者
  1. @airship_x = Game_Vehicle.new(:airship).x
  2. @airship_y = Game_Vehicle.new(:airship).y
复制代码
改为
  1. @airship_x =$game_map.airship.x
  2. @airship_y = $game_map.airship.y
复制代码

点评

谢谢了,难道您是哪个高手的马甲不成?  发表于 2012-3-28 00:15
http://rpg.blue/static/image/smiley/yct/A059.gif中国字认识都不到一半,哪的心情学英语呀!
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-10 08:40

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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