查看: 2622|回复: 3

[已经解决] 图标和光标错位了

[复制链接]
梦石
0
星屑
7306
在线时间
1244 小时
注册时间
2015-8-15
回帖
473
发表于 2016-2-9 21:11:53 | 显示全部楼层 |阅读模式

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

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

×
  1. #==============================================================================
  2. # ■ Window_MenuStatus
  3. #------------------------------------------------------------------------------
  4. #  显示菜单画面和同伴状态的窗口。
  5. #==============================================================================




  6. class Window_MenuStatus < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.     def initialize(actor_index = 0, equip_index = 0)#def initialize(index = 0)
  11.     super(0, 64, 1200, 480)
  12.     @item_max = $game_party.actors.size
  13.     self.contents = Bitmap.new(width - 32, height - 32)
  14.     refresh
  15.    # self.active = index
  16.     self.index =  index
  17.    # equip_index =
  18.     @column_max = 4
  19.   end
  20.   #--------------------------------------------------------------------------
  21.   # ● 刷新
  22.   #--------------------------------------------------------------------------
  23.     def refresh
  24.    
  25.     self.contents.clear

  26.    # @item_max = $game_party.actors.size
  27.     for i in 0...$game_party.actors.size
  28. #    draw_item(i, normal_color)
  29.     x = ( i + 1 ) * 92 +25
  30.     y = 44


  31.      

  32.     actor = $game_party.actors[i]
  33.     bitmap = Bitmap.new ("Graphics/Status/" + actor.id. to_s + "_h") #RPG::Cache.character(actor.character_name, actor.character_hue)
  34.     cw = bitmap.width
  35.     ch = bitmap.height
  36.     src_rect = Rect.new(0, 0, cw, ch)
  37.     self.contents.blt(x - ch , y - cw/ 2, bitmap, src_rect)
  38.     draw_actor_xdrs_lx(actor, x-ch, y)#转生次数


  39.     end
  40.   end
  41. #
  42.   
  43.   #--------------------------------------------------------------------------
  44.   # ● 更新光标举行
  45.   #--------------------------------------------------------------------------


  46.   #--------------------------------------------------------------------------
  47.   # ● 项目无效化
  48.   #     index : 项目编号
  49.   #--------------------------------------------------------------------------
  50.   def disable_item(index)
  51.     draw_item(index, disabled_color)
  52.   end
  53.   #--------------------------------------------------------------------------
  54.   # ● 刷新光标矩形
  55.   #--------------------------------------------------------------------------



  56.   
  57. def update_cursor_rect
  58.     # 光标位置不满 0 的情况下
  59.     if @index <= - 1
  60.       self.cursor_rect.empty
  61.       
  62.       return
  63.     end
  64.     # 获取当前的行
  65.     row = @index / @column_max
  66.     # 当前行被显示开头行前面的情况下
  67.     if row < self.top_row
  68.       # 从当前行向开头行滚动
  69.       self.top_row = row
  70.    end
  71.     # 当前行被显示末尾行之后的情况下
  72.     if row > self.top_row + (self.page_row_max - 1)
  73.       # 从当前行向末尾滚动
  74.       self.top_row = row - (self.page_row_max - 1)
  75.     end
  76.     # 计算光标的宽
  77.     cursor_width = 90
  78.     #cursor_width = 536 / (@column_max + 1) + 1  #光标大小
  79.     # 计算光标坐标
  80.    
  81.     x = 0 + @index % @column_max * (cursor_width + 1) - 4 #光标位置调节 覆盖31行
  82.     y = @index / @column_max * 128 - self.oy
  83.     # 更新国标矩形
  84.     self.cursor_rect.set(x, y, cursor_width, 128)#(x, y, cursor_width, 32)
  85.   
  86.     end

  87. end
复制代码
图片.jpg

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

梦石
0
星屑
3905
在线时间
1972 小时
注册时间
2013-1-3
回帖
9146
发表于 2016-2-9 22:43:45 | 显示全部楼层
把@column_max改一下

评分

参与人数 1星屑 +150 收起 理由
RyanBern + 150 认可答案

查看全部评分

《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴
回复

使用道具 举报

梦石
0
星屑
7306
在线时间
1244 小时
注册时间
2015-8-15
回帖
473
 楼主| 发表于 2016-2-10 09:11:00 | 显示全部楼层
紫英晓狼1130 发表于 2016-2-9 22:43
把@column_max改一下

我想把图片移过来

点评

那就需要改一下34和35行了,lz可以自己挑战一下  发表于 2016-2-10 11:35
回复

使用道具 举报

梦石
0
星屑
7306
在线时间
1244 小时
注册时间
2015-8-15
回帖
473
 楼主| 发表于 2016-2-10 12:01:54 | 显示全部楼层
本帖最后由 金芒芒 于 2016-2-10 16:32 编辑
  1. #==============================================================================
  2. # ■ Window_MenuStatus
  3. #------------------------------------------------------------------------------
  4. #  显示菜单画面和同伴状态的窗口。
  5. #==============================================================================




  6. class Window_MenuStatus < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.     def initialize(actor_index = 0, equip_index = 0)#def initialize(index = 0)
  11.     super(0, 64, 440, 480)
  12.     @item_max = $game_party.actors.size
  13.     self.contents = Bitmap.new(width - 32, 300)
  14.     refresh
  15.    # self.active = index
  16.     self.index =  index
  17.    # equip_index =
  18.     @column_max = 4
  19.   end
  20.   #--------------------------------------------------------------------------
  21.   # ● 刷新
  22.   #--------------------------------------------------------------------------
  23.     def refresh
  24.    
  25.     self.contents.clear

  26.    # @item_max = $game_party.actors.size
  27.     for i in 0...$game_party.actors.size
  28. #    draw_item(i, normal_color)
  29.   #  x = ( i + 1 ) * 92 +25
  30.   #  y = 44
  31. #    x = ( i + 1 ) % @column_max * (cursor_width + 1) - 4
  32. #   y = ( i + 1 ) / @column_max * 128 - self.oy
  33.    # x = 0 + index % 4 * (90 + 1) - 4
  34.   #  y = index / 90 * 128 - self.oy
  35.    # actor_width = 128
  36.     x =120 + i % 4 * (58 + 32)  # 根据包裹坐标修改过来的
  37.     y = 44 +  i / 4 * 128
  38.     actor = $game_party.actors[i]
  39.     bitmap = Bitmap.new ("Graphics/Status/" + actor.id. to_s + "_h") #RPG::Cache.character(actor.character_name, actor.character_hue)
  40.     cw = bitmap.width
  41.     ch = bitmap.height
  42.     src_rect = Rect.new(0, 0, cw, ch + 50)
  43.     self.contents.blt(x - ch , y  - cw/ 2, bitmap, src_rect) #src_rect
  44.     draw_actor_xdrs_lx(actor, x-ch, y)#转生次数


  45.   end
  46.   #   @item_max = $game_party.actors.size
  47.   #  if @item_max > 4
  48.    #   self.contents = Bitmap.new(width - 32, row_max * 32)
  49.    #   for i in 0...@item_max
  50.     #    raw_item(i, normal_color)
  51.     #  end
  52.   #  end
  53. end
  54. #
  55.   
  56.   #--------------------------------------------------------------------------
  57.   # ● 更新光标举行
  58.   #--------------------------------------------------------------------------


  59.   #--------------------------------------------------------------------------
  60.   # ● 项目无效化
  61.   #     index : 项目编号
  62.   #--------------------------------------------------------------------------
  63.   def disable_item(index)
  64.     draw_item(index, disabled_color)
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ● 刷新光标矩形
  68.   #--------------------------------------------------------------------------



  69.   
  70. def update_cursor_rect
  71.     # 光标位置不满 0 的情况下
  72.     if @index <= - 1
  73.       self.cursor_rect.empty
  74.       
  75.       return
  76.     end
  77.     # 获取当前的行
  78.     row = @index / @column_max
  79.     # 当前行被显示开头行前面的情况下
  80.     if row < self.top_row
  81.       # 从当前行向开头行滚动
  82.       self.top_row = row
  83.    end
  84.     # 当前行被显示末尾行之后的情况下
  85.     if row > self.top_row + (self.page_row_max - 1)
  86.       # 从当前行向末尾滚动
  87.       self.top_row = row - (self.page_row_max - 1)
  88.     end
  89.     # 计算光标的宽
  90.     cursor_width = 90
  91.     #cursor_width = 536 / (@column_max + 1) + 1  #光标大小
  92.     # 计算光标坐标
  93.    
  94.     x = 0 + @index % @column_max * (cursor_width + 1) - 4 #光标位置调节 覆盖31行
  95.     y = @index / @column_max * 128 - self.oy
  96.     # 更新国标矩形
  97.     self.cursor_rect.set(x, y, cursor_width, 128)#(x, y, cursor_width, 32)
  98.   
  99.     end

  100. end
复制代码
金芒芒 发表于 2016-2-10 09:11
我想把图片移过来


3Q,自己研究
QQ截图20160210163026.jpg
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部