查看: 2552|回复: 9

[已经解决] 道具栏显示大图的问题

[复制链接]
梦石
0
星屑
10345
在线时间
1117 小时
注册时间
2015-2-10
回帖
164
发表于 2015-11-30 19:41:43 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 RyanBern 于 2015-11-30 21:59 编辑

我要做一款解谜游戏,我想达成一种效果,就是在道具栏选中一个道具时,会在一个不会遮住选择框的地方显示一张特定的图片,这个怎么办?不要跟我说用公共事件,因为我放了个可以在事件执行时可以调出道具栏的脚本,如果这时再执行其它事件会出错……所以好像一定要用脚本,对了,我还放了一个道具分类的脚本,可能和各位做的脚本有冲突,所以放在这里,请各位想想如何不冲突脚本,又能达到我想的效果。这是道具分类脚本:

[pre lang="Ruby"]#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
#给物品分类,在物品的介绍后面加上@XXX,XXX可改为任意名字,同样后缀的物品获得
#归为一类,没有后缀的某认为贵重物品一类
#==============================================================================
# ■ Harts_Window_ItemTitle
#==============================================================================

class Harts_Window_ItemTitle < Window_Base
  def initialize
    super(0, 0, 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 120, 32, $data_system.words.item, 1)
  end
end

#==============================================================================
# ■ Harts_Window_ItemCommand
#==============================================================================

class Harts_Window_ItemCommand < Window_Selectable
  attr_accessor :commands
  #--------------------------------------------------------------------------
  # ● 初始化,生成commands窗口
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 160, 352)
    @commands = []
    #————————生成commands窗口
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        push = true
        for com in @commands
          if com == $data_items.desc
            push = false
          end
        end
        if push == true
          @commands.push($data_items.desc)
        end
      end
    end
    for i in 1...$data_weapons.size
      if $game_party.weapon_number(i) > 0
        push = true
        for com in @commands
          if com == $data_weapons.desc
            push = false
          end
        end
        if push == true
          @commands.push($data_weapons.desc)
        end
      end
    end
    for i in 1...$data_armors.size
      if $game_party.armor_number(i) > 0
        push = true
        for com in @commands
          if com == $data_armors.desc
            push = false
          end
        end
        if push == true
          @commands.push($data_armors.desc)
        end
      end
    end
    if @commands == []
      @commands.push("贵重物品")
    end      
    @item_max = @commands.size
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    y = index * 32
    self.contents.draw_text(4, y, 128, 32, @commands[index])
  end
  #--------------------------------------------------------------------------
  # 只描绘原文字
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(@commands[self.index])
  end
end

#==============================================================================
# ■ Window_Item
#==============================================================================

class Harts_Window_ItemList < Window_Selectable
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def initialize
    super(160, 0, 480, 416)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def set_item(command)
    refresh
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0 and $data_items.desc == command
        @data.push($data_items)
      end
    end
    for i in 1...$data_weapons.size
      if $game_party.weapon_number(i) > 0 and $data_weapons.desc == command
        @data.push($data_weapons)
      end
    end
    for i in 1...$data_armors.size
      if $game_party.armor_number(i) > 0 and $data_armors.desc == command
        @data.push($data_armors)
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.clear
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def item_number
    return @item_max
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    if item.is_a?(RPG::Item) and
      $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 32
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 400, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 416, y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

#==============================================================================
# ■ Harts_Scene_Item
#==============================================================================

class Scene_Item
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def main
    @itemtitle_window = Harts_Window_ItemTitle.new
    @itemcommand_window = Harts_Window_ItemCommand.new
    @command_index = @itemcommand_window.index
    @itemlist_window = Harts_Window_ItemList.new
    @itemlist_window.active = false
    @help_window = Window_Help.new
    @help_window.x = 0
    @help_window.y = 416
    @itemcommand_window.help_window = @help_window
    @itemlist_window.help_window = @help_window
    @target_window = Window_Target.new
    @target_window.visible = false
    @target_window.active = false
    @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @itemtitle_window.dispose
    @itemcommand_window.dispose
    @itemlist_window.dispose
    @help_window.dispose
    @target_window.dispose
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def update
    @itemtitle_window.update
    @itemcommand_window.update
    @itemlist_window.update
    @help_window.update
    @target_window.update
    if @command_index != @itemcommand_window.index
      @command_index = @itemcommand_window.index
      @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
    end
    if @itemcommand_window.active
      update_itemcommand
      return
    end
    if @itemlist_window.active
      update_itemlist
      return
    end
    if @target_window.active
      update_target
      return
    end
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def update_itemcommand
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      if @itemlist_window.item_number == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      @itemcommand_window.active = false
      @itemlist_window.active = true
      @itemlist_window.index = 0
      return
    end
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def update_itemlist
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @itemcommand_window.active = true
      @itemlist_window.active = false
      @itemlist_window.index = 0
      @itemcommand_window.index = @command_index
      return
    end
    if Input.trigger?(Input::C)
      @item = @itemlist_window.item
      unless @item.is_a?(RPG::Item)
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      unless $game_party.item_can_use?(@item.id)
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      $game_variables[5] = @item.id
      if @item.scope >= 3
        @itemlist_window.active = false
        @target_window.x = 304
        @target_window.visible = true
        @target_window.active = true
        if @item.scope == 4 || @item.scope == 6
          @target_window.index = -1
        else
          @target_window.index = 0
        end
      else
        if @item.common_event_id > 0
          $game_temp.common_event_id = @item.common_event_id
          $game_system.se_play(@item.menu_se)
            if @item.consumable
              $game_party.lose_item(@item.id, 1)
              @itemlist_window.draw_item(@itemlist_window.index)
            end
          $scene = Scene_Map.new
          return
        end
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def update_target
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      unless $game_party.item_can_use?(@item.id)
        @itemlist_window.refresh
      end
      @itemlist_window.active = true
      @target_window.visible = false
      @target_window.active = false
      @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
      return
    end
    if Input.trigger?(Input::C)
      if $game_party.item_number(@item.id) == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if @target_window.index == -1
        used = false
        for i in $game_party.actors
          used |= i.item_effect(@item)
        end
      end
      if @target_window.index >= 0
        target = $game_party.actors[@target_window.index]
        used = target.item_effect(@item)
      end
      if used
        $game_system.se_play(@item.menu_se)
        if @item.consumable
          $game_party.lose_item(@item.id, 1)
          @itemlist_window.draw_item(@itemlist_window.index)
          @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
        end
        @target_window.refresh
        if $game_party.all_dead?
          $scene = Scene_Gameover.new
          return
        end
        if @item.common_event_id > 0
          $game_temp.common_event_id = @item.common_event_id
          $scene = Scene_Map.new
          return
        end
      end
      unless used
        $game_system.se_play($data_system.buzzer_se)
      end
    return
    end
  end
end

#==============================================================================
# ■ RPG追加定义,使用@符号分类
#==============================================================================

module RPG
  class Weapon
    def description
      description = @description.split(/@/)[0]
      return description != nil ? description : ''
    end
    def desc
      desc = @description.split(/@/)[1]
      return desc != nil ? desc : "贵重物品"
    end
  end
  class Item
    def description
      description = @description.split(/@/)[0]
      return description != nil ? description : ''
    end
    def desc
      desc = @description.split(/@/)[1]
      return desc != nil ? desc : "贵重物品"
    end
  end
  class Armor
    def description
      description = @description.split(/@/)[0]
      return description != nil ? description : ''
    end
    def desc
      desc = @description.split(/@/)[1]
      return desc != nil ? desc : "贵重物品"
    end
  end
end

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
[/pre]

评分

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

查看全部评分

梦石
0
星屑
451
在线时间
228 小时
注册时间
2015-2-23
回帖
233
发表于 2015-12-1 09:46:10 | 显示全部楼层
本帖最后由 枫の叶 于 2015-12-1 10:03 编辑

物品场景所有窗口都把屏幕占满了,大图在哪儿放?还有大图有多大?
总要给出点建议什么的。一来就请求给做个大图显示,其他资料数据什么也没有,两眼一抹瞎。
制作XP特效,找我。
回复

使用道具 举报

梦石
0
星屑
10345
在线时间
1117 小时
注册时间
2015-2-10
回帖
164
 楼主| 发表于 2015-12-1 19:22:00 | 显示全部楼层
枫の叶 发表于 2015-12-1 09:46
物品场景所有窗口都把屏幕占满了,大图在哪儿放?还有大图有多大?
总要给出点建议什么的。一来就请求给做个 ...

说的也是,或者改为对选中的道具按下一个不是A键的其它键就可以显示特定图片,然后再按一下那个键就可以使图片消失,重新回到道具栏也行……

点评

至于图片的大小也就是显示图片原大吧,如果一定要说一个详细大小,就是和屏幕一样大。  发表于 2015-12-1 19:23
回复

使用道具 举报

梦石
0
星屑
451
在线时间
228 小时
注册时间
2015-2-23
回帖
233
发表于 2015-12-1 20:34:42 | 显示全部楼层
脚本加在物品分类脚本里。
大图片文件取名成物品或者装备图标名,再加一个 _b   。放在图标文件夹里。
按Z键是看大图。

Project1.rar (193.22 KB, 下载次数: 58)
制作XP特效,找我。
回复

使用道具 举报

梦石
0
星屑
10345
在线时间
1117 小时
注册时间
2015-2-10
回帖
164
 楼主| 发表于 2015-12-2 18:54:28 | 显示全部楼层
枫の叶 发表于 2015-12-1 20:34
脚本加在物品分类脚本里。
大图片文件取名成物品或者装备图标名,再加一个 _b   。放在图标文件夹里。
按Z ...

怎么没有用啊?按了好几下都没图,怎么回事?

点评

在选物品的时候按。  发表于 2015-12-2 19:08
回复

使用道具 举报

梦石
0
星屑
10345
在线时间
1117 小时
注册时间
2015-2-10
回帖
164
 楼主| 发表于 2015-12-3 19:25:54 | 显示全部楼层
枫の叶 发表于 2015-12-1 20:34
脚本加在物品分类脚本里。
大图片文件取名成物品或者装备图标名,再加一个 _b   。放在图标文件夹里。
按Z ...

但有些道具我本来不想放相应图片的,就是不可以查看大图的道具,可是按下相应键后就会说“没有找到图片”,有什么方法可以改进下,就是如果没有找到相应图片,按下Z键也就没有大图显示?
回复

使用道具 举报

梦石
0
星屑
451
在线时间
228 小时
注册时间
2015-2-23
回帖
233
发表于 2015-12-5 16:51:26 | 显示全部楼层
图片名不要取中文,图片格式必须是 png 的。

Project1.rar (219.72 KB, 下载次数: 46)

评分

参与人数 1梦石 +1 收起 理由
RyanBern + 1 认可答案

查看全部评分

制作XP特效,找我。
回复

使用道具 举报

梦石
0
星屑
10345
在线时间
1117 小时
注册时间
2015-2-10
回帖
164
 楼主| 发表于 2015-12-6 16:52:25 | 显示全部楼层
枫の叶 发表于 2015-12-5 16:51
图片名不要取中文,图片格式必须是 png 的。

我又发现了一个问题……用道具的图标名称来判定跳出什么图片不是很好,因为有几个道具它们都是同一个图标,能不能换一种判定方法?比如说根据道具名称或ID什么的……
回复

使用道具 举报

梦石
0
星屑
451
在线时间
228 小时
注册时间
2015-2-23
回帖
233
发表于 2015-12-6 17:13:45 | 显示全部楼层
那就分别取名,物品大图取名是:item物品ID ,1号物品:item1 ; 11号物品:item11
武器:weapon武器ID
防具:armor防具ID

Project1.rar (219.29 KB, 下载次数: 48)
制作XP特效,找我。
回复

使用道具 举报

梦石
0
星屑
10345
在线时间
1117 小时
注册时间
2015-2-10
回帖
164
 楼主| 发表于 2015-12-7 20:07:30 | 显示全部楼层
枫の叶 发表于 2015-12-6 17:13
那就分别取名,物品大图取名是:item物品ID ,1号物品:item1 ; 11号物品:item11
武器:weapon武器ID
防具 ...

谢谢您不厌其烦地回答我的问题,现在我的问题也终于解决了,我一定会做出好玩的游戏来报答您对我的帮助的!谢谢!
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部