查看: 2622|回复: 9

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

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

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

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

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

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

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

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

  18. #==============================================================================
  19. # ■ Harts_Window_ItemCommand
  20. #==============================================================================

  21. class Harts_Window_ItemCommand < Window_Selectable
  22.   attr_accessor :commands
  23.   #--------------------------------------------------------------------------
  24.   # ● 初始化,生成commands窗口
  25.   #--------------------------------------------------------------------------
  26.   def initialize
  27.     super(0, 64, 160, 352)
  28.     @commands = []
  29.     #————————生成commands窗口
  30.     for i in 1...$data_items.size
  31.       if $game_party.item_number(i) > 0
  32.         push = true
  33.         for com in @commands
  34.           if com == $data_items[i].desc
  35.             push = false
  36.           end
  37.         end
  38.         if push == true
  39.           @commands.push($data_items[i].desc)
  40.         end
  41.       end
  42.     end
  43.     for i in 1...$data_weapons.size
  44.       if $game_party.weapon_number(i) > 0
  45.         push = true
  46.         for com in @commands
  47.           if com == $data_weapons[i].desc
  48.             push = false
  49.           end
  50.         end
  51.         if push == true
  52.           @commands.push($data_weapons[i].desc)
  53.         end
  54.       end
  55.     end
  56.     for i in 1...$data_armors.size
  57.       if $game_party.armor_number(i) > 0
  58.         push = true
  59.         for com in @commands
  60.           if com == $data_armors[i].desc
  61.             push = false
  62.           end
  63.         end
  64.         if push == true
  65.           @commands.push($data_armors[i].desc)
  66.         end
  67.       end
  68.     end
  69.     if @commands == []
  70.       @commands.push("贵重物品")
  71.     end      
  72.     @item_max = @commands.size
  73.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  74.     refresh
  75.     self.index = 0
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   #--------------------------------------------------------------------------
  79.   def refresh
  80.     self.contents.clear
  81.     for i in 0...@item_max
  82.       draw_item(i, normal_color)
  83.     end
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   #--------------------------------------------------------------------------
  87.   def draw_item(index, color)
  88.     self.contents.font.color = color
  89.     y = index * 32
  90.     self.contents.draw_text(4, y, 128, 32, @commands[index])
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # 只描绘原文字
  94.   #--------------------------------------------------------------------------
  95.   def update_help
  96.     @help_window.set_text(@commands[self.index])
  97.   end
  98. end

  99. #==============================================================================
  100. # ■ Window_Item
  101. #==============================================================================

  102. class Harts_Window_ItemList < Window_Selectable
  103.   #--------------------------------------------------------------------------
  104.   #--------------------------------------------------------------------------
  105.   def initialize
  106.     super(160, 0, 480, 416)
  107.     refresh
  108.     self.index = 0
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   #--------------------------------------------------------------------------
  112.   def item
  113.     return @data[self.index]
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   #--------------------------------------------------------------------------
  117.   def refresh
  118.     if self.contents != nil
  119.       self.contents.dispose
  120.       self.contents = nil
  121.     end
  122.     @data = []
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   #--------------------------------------------------------------------------
  126.   def set_item(command)
  127.     refresh
  128.     for i in 1...$data_items.size
  129.       if $game_party.item_number(i) > 0 and $data_items[i].desc == command
  130.         @data.push($data_items[i])
  131.       end
  132.     end
  133.     for i in 1...$data_weapons.size
  134.       if $game_party.weapon_number(i) > 0 and $data_weapons[i].desc == command
  135.         @data.push($data_weapons[i])
  136.       end
  137.     end
  138.     for i in 1...$data_armors.size
  139.       if $game_party.armor_number(i) > 0 and $data_armors[i].desc == command
  140.         @data.push($data_armors[i])
  141.       end
  142.     end
  143.     @item_max = @data.size
  144.     if @item_max > 0
  145.       self.contents = Bitmap.new(width - 32, row_max * 32)
  146.       self.contents.clear
  147.       for i in 0...@item_max
  148.         draw_item(i)
  149.       end
  150.     end
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   #--------------------------------------------------------------------------
  154.   def item_number
  155.     return @item_max
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   #--------------------------------------------------------------------------
  159.   def draw_item(index)
  160.     item = @data[index]
  161.     case item
  162.     when RPG::Item
  163.       number = $game_party.item_number(item.id)
  164.     when RPG::Weapon
  165.       number = $game_party.weapon_number(item.id)
  166.     when RPG::Armor
  167.       number = $game_party.armor_number(item.id)
  168.     end
  169.     if item.is_a?(RPG::Item) and
  170.       $game_party.item_can_use?(item.id)
  171.       self.contents.font.color = normal_color
  172.     else
  173.       self.contents.font.color = disabled_color
  174.     end
  175.     x = 4
  176.     y = index * 32
  177.     bitmap = RPG::Cache.icon(item.icon_name)
  178.     opacity = self.contents.font.color == normal_color ? 255 : 128
  179.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  180.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  181.     self.contents.draw_text(x + 400, y, 16, 32, ":", 1)
  182.     self.contents.draw_text(x + 416, y, 24, 32, number.to_s, 2)
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   #--------------------------------------------------------------------------
  186.   def update_help
  187.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  188.   end
  189. end

  190. #==============================================================================
  191. # ■ Harts_Scene_Item
  192. #==============================================================================

  193. class Scene_Item
  194.   #--------------------------------------------------------------------------
  195.   #--------------------------------------------------------------------------
  196.   def main
  197.     @itemtitle_window = Harts_Window_ItemTitle.new
  198.     @itemcommand_window = Harts_Window_ItemCommand.new
  199.     @command_index = @itemcommand_window.index
  200.     @itemlist_window = Harts_Window_ItemList.new
  201.     @itemlist_window.active = false
  202.     @help_window = Window_Help.new
  203.     @help_window.x = 0
  204.     @help_window.y = 416
  205.     @itemcommand_window.help_window = @help_window
  206.     @itemlist_window.help_window = @help_window
  207.     @target_window = Window_Target.new
  208.     @target_window.visible = false
  209.     @target_window.active = false
  210.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  211.     Graphics.transition
  212.     loop do
  213.       Graphics.update
  214.       Input.update
  215.       update
  216.       if $scene != self
  217.         break
  218.       end
  219.     end
  220.     Graphics.freeze
  221.     @itemtitle_window.dispose
  222.     @itemcommand_window.dispose
  223.     @itemlist_window.dispose
  224.     @help_window.dispose
  225.     @target_window.dispose
  226.   end
  227.   #--------------------------------------------------------------------------
  228.   #--------------------------------------------------------------------------
  229.   def update
  230.     @itemtitle_window.update
  231.     @itemcommand_window.update
  232.     @itemlist_window.update
  233.     @help_window.update
  234.     @target_window.update
  235.     if @command_index != @itemcommand_window.index
  236.       @command_index = @itemcommand_window.index
  237.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  238.     end
  239.     if @itemcommand_window.active
  240.       update_itemcommand
  241.       return
  242.     end
  243.     if @itemlist_window.active
  244.       update_itemlist
  245.       return
  246.     end
  247.     if @target_window.active
  248.       update_target
  249.       return
  250.     end
  251.   end
  252.   #--------------------------------------------------------------------------
  253.   #--------------------------------------------------------------------------
  254.   def update_itemcommand
  255.     if Input.trigger?(Input::B)
  256.       $game_system.se_play($data_system.cancel_se)
  257.       $scene = Scene_Map.new
  258.       return
  259.     end
  260.     if Input.trigger?(Input::C)
  261.       if @itemlist_window.item_number == 0
  262.         $game_system.se_play($data_system.buzzer_se)
  263.         return
  264.       end
  265.       $game_system.se_play($data_system.decision_se)
  266.       @itemcommand_window.active = false
  267.       @itemlist_window.active = true
  268.       @itemlist_window.index = 0
  269.       return
  270.     end
  271.   end
  272.   #--------------------------------------------------------------------------
  273.   #--------------------------------------------------------------------------
  274.   def update_itemlist
  275.     if Input.trigger?(Input::B)
  276.       $game_system.se_play($data_system.cancel_se)
  277.       @itemcommand_window.active = true
  278.       @itemlist_window.active = false
  279.       @itemlist_window.index = 0
  280.       @itemcommand_window.index = @command_index
  281.       return
  282.     end
  283.     if Input.trigger?(Input::C)
  284.       @item = @itemlist_window.item
  285.       unless @item.is_a?(RPG::Item)
  286.         $game_system.se_play($data_system.buzzer_se)
  287.         return
  288.       end
  289.       unless $game_party.item_can_use?(@item.id)
  290.         $game_system.se_play($data_system.buzzer_se)
  291.         return
  292.       end
  293.       $game_system.se_play($data_system.decision_se)
  294.       $game_variables[5] = @item.id
  295.       if @item.scope >= 3
  296.         @itemlist_window.active = false
  297.         @target_window.x = 304
  298.         @target_window.visible = true
  299.         @target_window.active = true
  300.         if @item.scope == 4 || @item.scope == 6
  301.           @target_window.index = -1
  302.         else
  303.           @target_window.index = 0
  304.         end
  305.       else
  306.         if @item.common_event_id > 0
  307.           $game_temp.common_event_id = @item.common_event_id
  308.           $game_system.se_play(@item.menu_se)
  309.             if @item.consumable
  310.               $game_party.lose_item(@item.id, 1)
  311.               @itemlist_window.draw_item(@itemlist_window.index)
  312.             end
  313.           $scene = Scene_Map.new
  314.           return
  315.         end
  316.       end
  317.       return
  318.     end
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   #--------------------------------------------------------------------------
  322.   def update_target
  323.     if Input.trigger?(Input::B)
  324.       $game_system.se_play($data_system.cancel_se)
  325.       unless $game_party.item_can_use?(@item.id)
  326.         @itemlist_window.refresh
  327.       end
  328.       @itemlist_window.active = true
  329.       @target_window.visible = false
  330.       @target_window.active = false
  331.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  332.       return
  333.     end
  334.     if Input.trigger?(Input::C)
  335.       if $game_party.item_number(@item.id) == 0
  336.         $game_system.se_play($data_system.buzzer_se)
  337.         return
  338.       end
  339.       if @target_window.index == -1
  340.         used = false
  341.         for i in $game_party.actors
  342.           used |= i.item_effect(@item)
  343.         end
  344.       end
  345.       if @target_window.index >= 0
  346.         target = $game_party.actors[@target_window.index]
  347.         used = target.item_effect(@item)
  348.       end
  349.       if used
  350.         $game_system.se_play(@item.menu_se)
  351.         if @item.consumable
  352.           $game_party.lose_item(@item.id, 1)
  353.           @itemlist_window.draw_item(@itemlist_window.index)
  354.           @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  355.         end
  356.         @target_window.refresh
  357.         if $game_party.all_dead?
  358.           $scene = Scene_Gameover.new
  359.           return
  360.         end
  361.         if @item.common_event_id > 0
  362.           $game_temp.common_event_id = @item.common_event_id
  363.           $scene = Scene_Map.new
  364.           return
  365.         end
  366.       end
  367.       unless used
  368.         $game_system.se_play($data_system.buzzer_se)
  369.       end
  370.     return
  371.     end
  372.   end
  373. end

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

  377. module RPG
  378.   class Weapon
  379.     def description
  380.       description = @description.split(/@/)[0]
  381.       return description != nil ? description : ''
  382.     end
  383.     def desc
  384.       desc = @description.split(/@/)[1]
  385.       return desc != nil ? desc : "贵重物品"
  386.     end
  387.   end
  388.   class Item
  389.     def description
  390.       description = @description.split(/@/)[0]
  391.       return description != nil ? description : ''
  392.     end
  393.     def desc
  394.       desc = @description.split(/@/)[1]
  395.       return desc != nil ? desc : "贵重物品"
  396.     end
  397.   end
  398.   class Armor
  399.     def description
  400.       description = @description.split(/@/)[0]
  401.       return description != nil ? description : ''
  402.     end
  403.     def desc
  404.       desc = @description.split(/@/)[1]
  405.       return desc != nil ? desc : "贵重物品"
  406.     end
  407.   end
  408. end

  409. #==============================================================================
  410. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  411. #==============================================================================
复制代码

评分

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

查看全部评分

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

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

使用道具 举报

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

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

点评

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

使用道具 举报

梦石
0
星屑
10515
在线时间
1118 小时
注册时间
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
星屑
10515
在线时间
1118 小时
注册时间
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
星屑
10515
在线时间
1118 小时
注册时间
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.

在本版发帖返回顶部