查看: 2595|回复: 3

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

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

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

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

×
[pre lang="ruby"]#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
#  显示菜单画面和同伴状态的窗口。
#==============================================================================




class Window_MenuStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
    def initialize(actor_index = 0, equip_index = 0)#def initialize(index = 0)
    super(0, 64, 1200, 480)
    @item_max = $game_party.actors.size
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
   # self.active = index
    self.index =  index
   # equip_index =
    @column_max = 4
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
    def refresh
   
    self.contents.clear

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


     

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


    end
  end
#
  
  #--------------------------------------------------------------------------
  # ● 更新光标举行
  #--------------------------------------------------------------------------


  #--------------------------------------------------------------------------
  # ● 项目无效化
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------



  
def update_cursor_rect
    # 光标位置不满 0 的情况下
    if @index <= - 1
      self.cursor_rect.empty
      
      return
    end
    # 获取当前的行
    row = @index / @column_max
    # 当前行被显示开头行前面的情况下
    if row < self.top_row
      # 从当前行向开头行滚动
      self.top_row = row
   end
    # 当前行被显示末尾行之后的情况下
    if row > self.top_row + (self.page_row_max - 1)
      # 从当前行向末尾滚动
      self.top_row = row - (self.page_row_max - 1)
    end
    # 计算光标的宽
    cursor_width = 90
    #cursor_width = 536 / (@column_max + 1) + 1  #光标大小
    # 计算光标坐标
   
    x = 0 + @index % @column_max * (cursor_width + 1) - 4 #光标位置调节 覆盖31行
    y = @index / @column_max * 128 - self.oy
    # 更新国标矩形
    self.cursor_rect.set(x, y, cursor_width, 128)#(x, y, cursor_width, 32)
  
    end

end[/pre]
图片.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
星屑
7296
在线时间
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
星屑
7296
在线时间
1244 小时
注册时间
2015-8-15
回帖
473
 楼主| 发表于 2016-2-10 12:01:54 | 显示全部楼层
本帖最后由 金芒芒 于 2016-2-10 16:32 编辑

[pre lang="ruby"]#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
#  显示菜单画面和同伴状态的窗口。
#==============================================================================




class Window_MenuStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
    def initialize(actor_index = 0, equip_index = 0)#def initialize(index = 0)
    super(0, 64, 440, 480)
    @item_max = $game_party.actors.size
    self.contents = Bitmap.new(width - 32, 300)
    refresh
   # self.active = index
    self.index =  index
   # equip_index =
    @column_max = 4
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
    def refresh
   
    self.contents.clear

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


  end
  #   @item_max = $game_party.actors.size
  #  if @item_max > 4
   #   self.contents = Bitmap.new(width - 32, row_max * 32)
   #   for i in 0...@item_max
    #    raw_item(i, normal_color)
    #  end
  #  end
end
#
  
  #--------------------------------------------------------------------------
  # ● 更新光标举行
  #--------------------------------------------------------------------------


  #--------------------------------------------------------------------------
  # ● 项目无效化
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------



  
def update_cursor_rect
    # 光标位置不满 0 的情况下
    if @index <= - 1
      self.cursor_rect.empty
      
      return
    end
    # 获取当前的行
    row = @index / @column_max
    # 当前行被显示开头行前面的情况下
    if row < self.top_row
      # 从当前行向开头行滚动
      self.top_row = row
   end
    # 当前行被显示末尾行之后的情况下
    if row > self.top_row + (self.page_row_max - 1)
      # 从当前行向末尾滚动
      self.top_row = row - (self.page_row_max - 1)
    end
    # 计算光标的宽
    cursor_width = 90
    #cursor_width = 536 / (@column_max + 1) + 1  #光标大小
    # 计算光标坐标
   
    x = 0 + @index % @column_max * (cursor_width + 1) - 4 #光标位置调节 覆盖31行
    y = @index / @column_max * 128 - self.oy
    # 更新国标矩形
    self.cursor_rect.set(x, y, cursor_width, 128)#(x, y, cursor_width, 32)
  
    end

end[/pre]
金芒芒 发表于 2016-2-10 09:11
我想把图片移过来


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

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部