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

Project1

 找回密码
 注册会员
搜索

自己的窗口脚本请教(标题不知道怎样更专业一点)

查看数: 3860 | 评论数: 11 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2019-3-6 14:28

正文摘要:

本帖最后由 阮声悠悠 于 2019-3-7 23:33 编辑 找到了一个更合适的解决方案,所以对我来说这张帖子的问题已经不重要了。 这是一个罗列道具的脚本。罗列的数组在88行 我希望窗口的第一行罗列物品ID为   ...

回复

融血 发表于 2019-3-8 00:12:03

光标的刷新和移动都可以在Window_Selectable里设置,你可以复制这个脚本然后重命名类的名字,之后按照需要改就行了
融血 发表于 2019-3-7 23:38:49
本帖最后由 融血 于 2019-3-7 23:43 编辑

看错了,抱歉

点评

谢啦,已经找到更合理的处理方式了  发表于 2019-3-7 23:50
融血 发表于 2019-3-7 23:38:14
另外你想要的是不是大概就是这种效果?
融血 发表于 2019-3-7 23:27:46
参考Window_Item,里面@column_max就是列数,更改这个值就可以了
KB.Driver 发表于 2019-3-6 19:21:39
灯笼菜刀王 发表于 2019-3-6 19:14
def update_cursor_rect
   if @data[self.index][3] != 0
       self.cursor_rect.set(x,y,width,height) ...

说实在的,弄这么麻烦还不如不显示光标,输入只用来做上下翻页用(
灯笼菜刀王 发表于 2019-3-6 19:14:13
def update_cursor_rect
   if @data[self.index][3] != 0
       self.cursor_rect.set(x,y,width,height)
   elsif @data[self.index][2] != 0
       self.cursor_rect.set(x,y,width,height)
   elsif @data[self.index][1] != 0
       self.cursor_rect.set(x,y,width,height)
  else
      self.cursor_rect.set(x,y,width,height)
  end
end

这里也根据道具数量手动画吧XD
阮声悠悠 发表于 2019-3-6 16:37:05
KB.Driver 发表于 2019-3-6 15:50
XP的脚本结构本来就不太好,再不认真研究就自己瞎搞的话谁也帮不了你。
把你的窗口重新写了一遍。

貌似可以一行出现不同个数,因为实际上还是一列……
  1. #$scene = Scene_xgqBhuoZhuoTuJian.new打开脚本


  2. class Scene_xgqBhuoZhuoTuJian
  3.   #--------------------------------------------------------------------------
  4.   # ● 主处理
  5.   #--------------------------------------------------------------------------
  6.   def main
  7.     screen = Spriteset_Map.new
  8.     # 生成窗口
  9.     @tujian_window = Window_BhuoZhuoTuJian.new
  10.     @tujian_window.z=1000
  11.     # 生成目标窗口 (设置为不可见・不活动)
  12.     @target_window = Window_Target.new
  13.     @target_window.visible = false
  14.     @target_window.active = false
  15.     @target_window.z=1896
  16.     # 执行过渡
  17.     Graphics.transition
  18.     # 主循环
  19.     loop do
  20.       # 刷新游戏画面
  21.       Graphics.update
  22.       # 刷新输入信息
  23.       Input.update
  24.       # 刷新画面
  25.       update
  26.       # 如果画面切换的话就中断循环
  27.       if $scene != self
  28.         break
  29.       end
  30.     end
  31.     # 准备过渡
  32.     Graphics.freeze
  33.     # 释放窗口
  34.     screen.dispose
  35.     @tujian_window.dispose
  36.     @target_window.dispose
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 刷新画面
  40.   #--------------------------------------------------------------------------
  41.   def update
  42.     # 刷新窗口
  43.     @tujian_window.update
  44.     @target_window.update
  45.     # 图鉴窗口被激活的情况下: 调用 update_tujian
  46.     if @tujian_window.active
  47.       update_tujian
  48.       return
  49.     end
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ● 刷新画面 (特技窗口被激活的情况下)
  53.   #--------------------------------------------------------------------------
  54.   def update_tujian
  55.     # 按下 B 键的情况下
  56.     if Input.trigger?(Input::B)
  57.       # 演奏取消 SE
  58.       $game_system.se_play($data_system.cancel_se)
  59.       # 切换到地图
  60.       $scene = Scene_Map.new
  61.       return
  62.     end
  63.   end
  64. end



  65. class Window_BhuoZhuoTuJian < Window_Selectable
  66.   #--------------------------------------------------------------------------
  67.   # ● 初始化对像
  68.   #--------------------------------------------------------------------------
  69.   def initialize
  70.     super(0, 0, 640, 480)
  71.     @column_max = 1
  72.     refresh
  73.     self.index = 0
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 刷新
  77.   #--------------------------------------------------------------------------
  78.   def refresh
  79.     @data = [
  80.     [   1,    2,    3,    0,    0],#第一行出现的物品ID,如有有0就不出现
  81.     [   4,    5,    6,    0,    0],
  82.     [   7,    8,    9,    0,    0],
  83.     [   58,   59,   0,    0,    0],
  84.     [   115,  0,    0,    0,    0],
  85.     [   236,  237,  106,  107,  0],
  86.     [   789,  790,  791,  792,  0]

  87.     ]
  88.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  89.     @item_max = @data.size
  90.     if @item_max > 0
  91.       self.contents = Bitmap.new(width - 32, row_max * 32)
  92.       for i in 0...@item_max
  93.         draw_item(i)
  94.         draw_itemer(i)
  95.         draw_itemsan(i)
  96.         draw_itemsi(i)
  97.       end
  98.     end
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● 描绘项目
  102.   #     index : 项目编号
  103.   #--------------------------------------------------------------------------
  104.   def draw_item(index)
  105.     skill = @data[index]
  106.     x = 4
  107.     y = index * 32
  108.     bitmap = RPG::Cache.icon($data_items[@data[index][0]].icon_name)
  109.     self.contents.blt(x, y + 4, bitmap, bitmap.rect)
  110.     self.contents.draw_text(x + 28, y, 204, 32, $data_items[@data[index][0]].name, 0)
  111.   end
  112.   def draw_itemer(index)
  113. if @data[index][1] != 0
  114.     skill = @data[index]
  115.     x = 152
  116.     y = index * 32
  117.     bitmap = RPG::Cache.icon($data_items[@data[index][1]].icon_name)
  118.     self.contents.blt(x, y + 4, bitmap, bitmap.rect)
  119.     self.contents.draw_text(x + 28, y, 204, 32, $data_items[@data[index][1]].name, 0)
  120. end
  121.   end
  122.   def draw_itemsan(index)
  123. if @data[index][2] != 0
  124.     skill = @data[index]
  125.     x = 304
  126.     y = index * 32
  127.     bitmap = RPG::Cache.icon($data_items[@data[index][2]].icon_name)
  128.     self.contents.blt(x, y + 4, bitmap, bitmap.rect)
  129.     self.contents.draw_text(x + 28, y, 204, 32, $data_items[@data[index][2]].name, 0)
  130. end
  131.   end
  132.   def draw_itemsi(index)
  133. if @data[index][3] != 0
  134.     skill = @data[index]
  135.     x = 462
  136.     y = index * 32
  137.     bitmap = RPG::Cache.icon($data_items[@data[index][3]].icon_name)
  138.     self.contents.blt(x, y + 4, bitmap, bitmap.rect)
  139.     self.contents.draw_text(x + 28, y, 204, 32, $data_items[@data[index][3]].name, 0)
  140. end
  141.   end
  142. end
复制代码
KB.Driver 发表于 2019-3-6 15:50:11
XP的脚本结构本来就不太好,再不认真研究就自己瞎搞的话谁也帮不了你。
把你的窗口重新写了一遍。

RUBY 代码复制
  1. class Window_BhuoZhuoTuJian < Window_Selectable
  2.   #--------------------------------------------------------------------------
  3.   # ● 初始化对像
  4.   #--------------------------------------------------------------------------
  5.   def initialize
  6.     super(0, 0, 640, 480)
  7.     @column_max = 3  ##
  8.     self.index = 0
  9.     init_data
  10.     refresh
  11.   end
  12.  
  13.   def init_data
  14.     @data = [
  15.        1,    2,    3,#第一行出现的物品ID,如有有0就不出现
  16.        4,    5,    6,
  17.        7,    8,    9,
  18.        58,   59,   0,
  19.        115,  0,    0,
  20.        236,  237,  106,  107,  0
  21.     ]
  22.     @item_max = @data.size
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 刷新
  26.   #--------------------------------------------------------------------------
  27.   def refresh
  28.     if self.contents
  29.       self.contents.clear
  30.     else
  31.       self.contents = Bitmap.new(width - 32, @item_max * 32)
  32.     end
  33.     @item_max.times{|i| draw_item(i)}
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ● 描绘项目
  37.   #     index : 项目编号
  38.   #--------------------------------------------------------------------------
  39.   def draw_item(index)
  40.     x = index % @column_max * (self.cursor_rect.width + 32)
  41.     y = index / @column_max * 32
  42.     if (id = @data[index]) > 0
  43.       bitmap = RPG::Cache.icon($data_items[id].icon_name)
  44.       self.contents.blt(x, y + 4, bitmap, bitmap.rect)
  45.       self.contents.draw_text(x + 28, y, 204, 32, $data_items[id].name)
  46.     end
  47.   end
  48. end




提醒你几点,想一下下面几个问题
@column_max是什么,@data数组套数组能改变列数吗?
self.contents是什么,有必要每次refresh生成新对象吗?
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-5-6 06:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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