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

Project1

 找回密码
 注册会员
搜索
查看: 1457|回复: 4
打印 上一主题 下一主题

[已经解决] 【请教】在物品分类脚本中怎么实现菜单透明

[复制链接]

Lv2.观梦者

梦石
0
星屑
590
在线时间
392 小时
注册时间
2012-1-20
帖子
223

开拓者

跳转到指定楼层
1
发表于 2014-3-1 23:50:22 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我在游戏中加了菜单透明脚本和物品分类脚本,但是在查看物品时就无法菜单透明了= =
怎么让查看物品时也是菜单透明状态- -?
↓这是物品分类的脚本
RUBY 代码复制
  1. # ————————————————————————————————————
  2. # 本脚本来自[url]www.66rpg.com[/url],转载请保留此信息
  3. # ————————————————————————————————————
  4.  
  5. #==============================================================================
  6. # ■ Harts_Window_ItemTitle
  7. #==============================================================================
  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. #==============================================================================
  20. # ■ Harts_Window_ItemCommand
  21. #==============================================================================
  22.  
  23. class Harts_Window_ItemCommand < Window_Selectable
  24.   attr_accessor :commands
  25.   #--------------------------------------------------------------------------
  26.   # ● 初始化,生成commands窗口
  27.   #--------------------------------------------------------------------------
  28.   def initialize
  29.     super(0, 64, 160, 352)
  30.     self.contents = Bitmap.new(width - 32, height - 32)
  31.     @commands = []
  32.     #————————生成commands窗口
  33.     for i in 1...$data_items.size
  34.       if $game_party.item_number(i) > 0
  35.         push = true
  36.         for com in @commands
  37.           if com == $data_items[i].desc
  38.             push = false
  39.           end
  40.         end
  41.         if push == true
  42.           @commands.push($data_items[i].desc)
  43.         end
  44.       end
  45.     end
  46.     for i in 1...$data_weapons.size
  47.       if $game_party.weapon_number(i) > 0
  48.         push = true
  49.         for com in @commands
  50.           if com == $data_weapons[i].desc
  51.             push = false
  52.           end
  53.         end
  54.         if push == true
  55.           @commands.push($data_weapons[i].desc)
  56.         end
  57.       end
  58.     end
  59.     for i in 1...$data_armors.size
  60.       if $game_party.armor_number(i) > 0
  61.         push = true
  62.         for com in @commands
  63.           if com == $data_armors[i].desc
  64.             push = false
  65.           end
  66.         end
  67.         if push == true
  68.           @commands.push($data_armors[i].desc)
  69.         end
  70.       end
  71.     end
  72.     if @commands == []
  73.       @commands.push("普通物品")
  74.     end      
  75.     @item_max = @commands.size
  76.     refresh
  77.     self.index = 0
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   #--------------------------------------------------------------------------
  81.   def refresh
  82.     self.contents.clear
  83.     for i in 0...@item_max
  84.       draw_item(i, normal_color)
  85.     end
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   #--------------------------------------------------------------------------
  89.   def draw_item(index, color)
  90.     self.contents.font.color = color
  91.     y = index * 32
  92.     self.contents.draw_text(4, y, 128, 32, @commands[index])
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # 只描绘原文字
  96.   #--------------------------------------------------------------------------
  97.   def update_help
  98.     @help_window.set_text(@commands[self.index])
  99.   end
  100. end
  101.  
  102. #==============================================================================
  103. # ■ Window_Item
  104. #==============================================================================
  105.  
  106. class Harts_Window_ItemList < Window_Selectable
  107.   #--------------------------------------------------------------------------
  108.   #--------------------------------------------------------------------------
  109.   def initialize
  110.     super(160, 0, 480, 416)
  111.     refresh
  112.     self.index = 0
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   #--------------------------------------------------------------------------
  116.   def item
  117.     return @data[self.index]
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   #--------------------------------------------------------------------------
  121.   def refresh
  122.     if self.contents != nil
  123.       self.contents.dispose
  124.       self.contents = nil
  125.     end
  126.     @data = []
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   #--------------------------------------------------------------------------
  130.   def set_item(command)
  131.     refresh
  132.     for i in 1...$data_items.size
  133.       if $game_party.item_number(i) > 0 and $data_items[i].desc == command
  134.         @data.push($data_items[i])
  135.       end
  136.     end
  137.     for i in 1...$data_weapons.size
  138.       if $game_party.weapon_number(i) > 0 and $data_weapons[i].desc == command
  139.         @data.push($data_weapons[i])
  140.       end
  141.     end
  142.     for i in 1...$data_armors.size
  143.       if $game_party.armor_number(i) > 0 and $data_armors[i].desc == command
  144.         @data.push($data_armors[i])
  145.       end
  146.     end
  147.     @item_max = @data.size
  148.     if @item_max > 0
  149.       self.contents = Bitmap.new(width - 32, row_max * 32)
  150.       self.contents.clear
  151.       for i in 0...@item_max
  152.         draw_item(i)
  153.       end
  154.     end
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   #--------------------------------------------------------------------------
  158.   def item_number
  159.     return @item_max
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   #--------------------------------------------------------------------------
  163.   def draw_item(index)
  164.     item = @data[index]
  165.     case item
  166.     when RPG::Item
  167.       number = $game_party.item_number(item.id)
  168.     when RPG::Weapon
  169.       number = $game_party.weapon_number(item.id)
  170.     when RPG::Armor
  171.       number = $game_party.armor_number(item.id)
  172.     end
  173.     if item.is_a?(RPG::Item) and
  174.       $game_party.item_can_use?(item.id)
  175.       self.contents.font.color = normal_color
  176.     else
  177.       self.contents.font.color = disabled_color
  178.     end
  179.     x = 4
  180.     y = index * 32
  181.     bitmap = RPG::Cache.icon(item.icon_name)
  182.     opacity = self.contents.font.color == normal_color ? 255 : 128
  183.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  184.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  185.     self.contents.draw_text(x + 400, y, 16, 32, ":", 1)
  186.     self.contents.draw_text(x + 416, y, 24, 32, number.to_s, 2)
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   #--------------------------------------------------------------------------
  190.   def update_help
  191.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  192.   end
  193. end
  194.  
  195. #==============================================================================
  196. # ■ Harts_Scene_Item
  197. #==============================================================================
  198.  
  199. class Scene_Item
  200.   #--------------------------------------------------------------------------
  201.   #--------------------------------------------------------------------------
  202.   def main
  203.     @itemtitle_window = Harts_Window_ItemTitle.new
  204.     @itemcommand_window = Harts_Window_ItemCommand.new
  205.     @command_index = @itemcommand_window.index
  206.     @itemlist_window = Harts_Window_ItemList.new
  207.     @itemlist_window.active = false
  208.     @help_window = Window_Help.new
  209.     @help_window.x = 0
  210.     @help_window.y = 416
  211.     @itemcommand_window.help_window = @help_window
  212.     @itemlist_window.help_window = @help_window
  213.     @target_window = Window_Target.new
  214.     @target_window.visible = false
  215.     @target_window.active = false
  216.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  217.     Graphics.transition
  218.     loop do
  219.       Graphics.update
  220.       Input.update
  221.       update
  222.       if $scene != self
  223.         break
  224.       end
  225.     end
  226.     Graphics.freeze
  227.     @itemtitle_window.dispose
  228.     @itemcommand_window.dispose
  229.     @itemlist_window.dispose
  230.     @help_window.dispose
  231.     @target_window.dispose
  232.   end
  233.   #--------------------------------------------------------------------------
  234.   #--------------------------------------------------------------------------
  235.   def update
  236.     @itemtitle_window.update
  237.     @itemcommand_window.update
  238.     @itemlist_window.update
  239.     @help_window.update
  240.     @target_window.update
  241.     if @command_index != @itemcommand_window.index
  242.       @command_index = @itemcommand_window.index
  243.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  244.     end
  245.     if @itemcommand_window.active
  246.       update_itemcommand
  247.       return
  248.     end
  249.     if @itemlist_window.active
  250.       update_itemlist
  251.       return
  252.     end
  253.     if @target_window.active
  254.       update_target
  255.       return
  256.     end
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   #--------------------------------------------------------------------------
  260.   def update_itemcommand
  261.     if Input.trigger?(Input::B)
  262.       $game_system.se_play($data_system.cancel_se)
  263.       $scene = Scene_Menu.new(0)
  264.       return
  265.     end
  266.     if Input.trigger?(Input::C)
  267.       if @itemlist_window.item_number == 0
  268.         $game_system.se_play($data_system.buzzer_se)
  269.         return
  270.       end
  271.       $game_system.se_play($data_system.decision_se)
  272.       @itemcommand_window.active = false
  273.       @itemlist_window.active = true
  274.       @itemlist_window.index = 0
  275.       return
  276.     end
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   #--------------------------------------------------------------------------
  280.   def update_itemlist
  281.     if Input.trigger?(Input::B)
  282.       $game_system.se_play($data_system.cancel_se)
  283.       @itemcommand_window.active = true
  284.       @itemlist_window.active = false
  285.       @itemlist_window.index = 0
  286.       @itemcommand_window.index = @command_index
  287.       return
  288.     end
  289.     if Input.trigger?(Input::C)
  290.       @item = @itemlist_window.item
  291.       unless @item.is_a?(RPG::Item)
  292.         $game_system.se_play($data_system.buzzer_se)
  293.         return
  294.       end
  295.       unless $game_party.item_can_use?(@item.id)
  296.         $game_system.se_play($data_system.buzzer_se)
  297.         return
  298.       end
  299.       $game_system.se_play($data_system.decision_se)
  300.       if @item.scope >= 3
  301.         @itemlist_window.active = false
  302.         @target_window.x = 304
  303.         @target_window.visible = true
  304.         @target_window.active = true
  305.         if @item.scope == 4 || @item.scope == 6
  306.           @target_window.index = -1
  307.         else
  308.           @target_window.index = 0
  309.         end
  310.       else
  311.         if @item.common_event_id > 0
  312.           $game_temp.common_event_id = @item.common_event_id
  313.           $game_system.se_play(@item.menu_se)
  314.             if @item.consumable
  315.               $game_party.lose_item(@item.id, 1)
  316.               @itemlist_window.draw_item(@itemlist_window.index)
  317.             end
  318.           $scene = Scene_Map.new
  319.           return
  320.         end
  321.       end
  322.       return
  323.     end
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   #--------------------------------------------------------------------------
  327.   def update_target
  328.     if Input.trigger?(Input::B)
  329.       $game_system.se_play($data_system.cancel_se)
  330.       unless $game_party.item_can_use?(@item.id)
  331.         @itemlist_window.refresh
  332.       end
  333.       @itemlist_window.active = true
  334.       @target_window.visible = false
  335.       @target_window.active = false
  336.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  337.       return
  338.     end
  339.     if Input.trigger?(Input::C)
  340.       if $game_party.item_number(@item.id) == 0
  341.         $game_system.se_play($data_system.buzzer_se)
  342.         return
  343.       end
  344.       if @target_window.index == -1
  345.         used = false
  346.         for i in $game_party.actors
  347.           used |= i.item_effect(@item)
  348.         end
  349.       end
  350.       if @target_window.index >= 0
  351.         target = $game_party.actors[@target_window.index]
  352.         used = target.item_effect(@item)
  353.       end
  354.       if used
  355.         $game_system.se_play(@item.menu_se)
  356.         if @item.consumable
  357.           $game_party.lose_item(@item.id, 1)
  358.           @itemlist_window.draw_item(@itemlist_window.index)
  359.           @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  360.         end
  361.         @target_window.refresh
  362.         if $game_party.all_dead?
  363.           $scene = Scene_Gameover.new
  364.           return
  365.         end
  366.         if @item.common_event_id > 0
  367.           $game_temp.common_event_id = @item.common_event_id
  368.           $scene = Scene_Map.new
  369.           return
  370.         end
  371.       end
  372.       unless used
  373.         $game_system.se_play($data_system.buzzer_se)
  374.       end
  375.     return
  376.     end
  377.   end
  378. end
  379.  
  380. #==============================================================================
  381. # ■ RPG追加定义,使用@符号分类
  382. #==============================================================================
  383.  
  384. module RPG
  385.   class Weapon#武器
  386.     def description
  387.       description = @description.split(/@/)[0]
  388.       return description != nil ? description : ''
  389.     end
  390.     def desc
  391.       desc = @description.split(/@/)[1]
  392.       return desc != nil ? desc : "武器防具"
  393.     end
  394.   end
  395.   class Item#物品
  396.     def description
  397.       description = @description.split(/@/)[0]
  398.       return description != nil ? description : ''
  399.     end
  400.     def desc
  401.       desc = @description.split(/@/)[1]
  402.       return desc != nil ? desc : "物品"
  403.     end
  404.   end
  405.   class Armor#防具
  406.     def description
  407.       description = @description.split(/@/)[0]
  408.       return description != nil ? description : ''
  409.     end
  410.     def desc
  411.       desc = @description.split(/@/)[1]
  412.       return desc != nil ? desc : "武器防具"
  413.     end
  414.   end
  415. end
支持一下下我的这个游戏吧~~
大雄与空间军团

Lv3.寻梦者

○赛

梦石
0
星屑
1249
在线时间
1276 小时
注册时间
2013-1-22
帖子
2246

贵宾

2
发表于 2014-3-2 07:47:17 | 只看该作者
Scene_Item里面改透明度
回复 支持 反对

使用道具 举报

Lv4.逐梦者

「Pemercyia」


Urhurrenna

梦石
0
星屑
9397
在线时间
2748 小时
注册时间
2008-9-5
帖子
3543

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

3
发表于 2014-3-2 18:50:03 | 只看该作者
两个脚本都是Main前insert吧?
需要注意的是【菜单透明脚本】请放在最下方~
起码放在物品分类脚本的下方~

评分

参与人数 1星屑 +70 收起 理由
天地有正气 + 70 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
590
在线时间
392 小时
注册时间
2012-1-20
帖子
223

开拓者

4
 楼主| 发表于 2014-3-8 19:02:39 | 只看该作者
cinderelmini 发表于 2014-3-2 18:50
两个脚本都是Main前insert吧?
需要注意的是【菜单透明脚本】请放在最下方~
起码放在物品分类脚本的下方~ ...

哦,原来是这样子啊,谢谢咯~
支持一下下我的这个游戏吧~~
大雄与空间军团
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-9-30 15:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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