幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1751|回复: 2

[RMXP] 请教菜单图标化的脚本问题

[复制链接]

6

主题

13

帖子

116

积分

③业余

积分
116
发表于 2010-3-23 16:02:46 | 显示全部楼层 |阅读模式
为什么我改变了图标位置鼠标就无法控制了 请问下应该在哪判断?
这是原脚本
  1. #==============================================================================
  2. # ■ 菜单图标化
  3. #------------------------------------------------------------------------------
  4. #  战斗菜单改成了仙剑的模样
  5. #   By whbm
  6. #==============================================================================
  7. module Momo_IconCommand
  8.   # 图标名称设定
  9.   ATTACK_ICON_NAME = "Attack" # 攻撃
  10.   SKILL_ICON_NAME = "Skill"   # 特技
  11.   GUARD_ICON_NAME = "Guard"  # 防御
  12.   ITEM_ICON_NAME = "Thing"     # 物品
  13.   # X坐标修正
  14.   X_PLUS = -320
  15.   # Y坐标修正
  16.   Y_PLUS = -100
  17.   # 选择时图标的动作
  18.   # 0:静止 1:放大
  19.   SELECT_TYPE = 0
  20.   # 闪烁时光芒的颜色
  21.   FLASH_COLOR = Color.new(255, 255, 255, 128)
  22.   # 闪烁时间
  23.   FLASH_DURATION = 10
  24.   # 闪烁间隔
  25.   FLASH_INTERVAL = 20
  26.   # 是否写出文字的名称
  27.   COM_NAME_DROW = false
  28.   # 文字名称是否移动
  29.   COM_NAME_MOVE = true
  30.   # 文字内容
  31.   ATTACK_NAME = "攻击"    # 攻击
  32.   SKILL_NAME = "特技"   # 特技
  33.   GUARD_NAME = "防御"     # 防御
  34.   ITEM_NAME = "物品"  # 物品
  35.   # 文字颜色
  36.   COM_NAME_COLOR = Color.new(255, 255, 255, 255)
  37.   # 文字坐标修正
  38.   COM_NAME_X_PLUS = 0
  39.   COM_NAME_Y_PLUS = 0
  40. end
  41. class Window_CommandIcon < Window_Selectable
  42.   attr_accessor :last_index
  43.   #--------------------------------------------------------------------------
  44.   # ● オブジェクト初期化
  45.   #--------------------------------------------------------------------------
  46.   def initialize(x, y, commands)
  47.     super(x, y, 37, 37)
  48.     # ウィンドウスキンに空文字列を指定してウィンドウを描画しないようにする
  49.     self.windowskin = RPG::Cache.windowskin("")
  50.     @item_max = commands.size
  51.     @commands = commands
  52.     @column_max = commands.size
  53.     @index = 0
  54.     @last_index = nil
  55.     @name_sprite = nil
  56.     @sprite = []
  57.     refresh
  58.   end
  59.   def dispose
  60.     super
  61.     for sprite in @sprite
  62.       sprite.dispose unless sprite.nil?
  63.     end
  64.     @name_sprite.dispose unless @name_sprite.nil?
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ● リフレッシュ
  68.   #--------------------------------------------------------------------------
  69.   def refresh
  70.     @name_sprite.dispose unless @name_sprite.nil?
  71.     for sprite in @sprite
  72.       sprite.dispose unless sprite.nil?
  73.     end
  74.     @name_sprite = nil
  75.     draw_com_name if Momo_IconCommand::COM_NAME_DROW
  76.     @sprite = []
  77.     for i in 0...@item_max
  78.       draw_item(i)
  79.     end
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # ● 項目の描画
  83.   #--------------------------------------------------------------------------
  84.   def draw_item(index)
  85.     @sprite[index] = Sprite_Icon.new(nil, @commands[index])
  86.     @sprite[index].z = self.z + 1
  87.   end
  88.   def draw_com_name
  89.     @name_sprite = Sprite_Comm_Name.new(nil, get_com_name)
  90.   end
  91.   # 更新
  92.   def update
  93.     super
  94.     icon_update
  95.     com_name_update if Momo_IconCommand::COM_NAME_DROW
  96.     if move_index?
  97.       @last_index = self.index
  98.     end
  99.   end
  100.   # アイコンの更新
  101.   def icon_update
  102.     qx = 25
  103.     qy = 405
  104.     for i in 0...@sprite.size
  105.       @sprite[i].active = (self.index == i)
  106.       @sprite[0].x = 24 +qx
  107.       @sprite[0].y = 0 +qy
  108.       @sprite[1].x = 0 + qx
  109.       @sprite[1].y = 25 + qy
  110.       @sprite[2].x = 24 + qx
  111.       @sprite[2].y = 49 + qy
  112.       @sprite[3].x = 49 + qx
  113.       @sprite[3].y = 25 + qy
  114.       #@sprite[i].x = self.x + i * 56
  115.       #@sprite[i].y = self.y + 0
  116.       @sprite[i].z = (self.index == i) ? self.z + 2 : self.z + 1
  117.       @sprite[i].visible = self.visible
  118.       @sprite[i].update
  119.     end
  120.   end
  121.   # コマンドネームの更新
  122.   def com_name_update
  123.     if move_index?
  124.       @name_sprite.name = get_com_name
  125.     end
  126.     @name_sprite.x = self.x - 12 + Momo_IconCommand::COM_NAME_X_PLUS
  127.     @name_sprite.y = self.y - 40 + Momo_IconCommand::COM_NAME_Y_PLUS
  128.     @name_sprite.z = self.z + 1
  129.     @name_sprite.active = self.active
  130.     @name_sprite.visible = self.visible
  131.     @name_sprite.update
  132.   end
  133.   def get_com_name
  134.     make_name_set if @name_set.nil?
  135.     name = @name_set[self.index]
  136.     name = "" if name.nil?
  137.     return name
  138.   end
  139.   def make_name_set
  140.     @name_set = []
  141.     @name_set[0] = Momo_IconCommand::ATTACK_NAME
  142.     @name_set[1] = Momo_IconCommand::SKILL_NAME
  143.     @name_set[2] = Momo_IconCommand::GUARD_NAME
  144.     @name_set[3] = Momo_IconCommand::ITEM_NAME
  145.   end
  146.   def move_index?
  147.     return self.index != @last_index
  148.   end
  149.   def need_reset
  150.     @name_sprite.need_reset = true if Momo_IconCommand::COM_NAME_DROW
  151.   end
  152. end
  153. # アイコン用スプライト
  154. class Sprite_Icon < Sprite
  155.   attr_accessor :active
  156.   attr_accessor :icon_name
  157.   #--------------------------------------------------------------------------
  158.   # ● オブジェクト初期化
  159.   #--------------------------------------------------------------------------
  160.   def initialize(viewport, icon_name)
  161.     super(viewport)
  162.     @icon_name = icon_name
  163.     @last_icon = @icon_name
  164.     @count = 0
  165.     self.bitmap = RPG::Cache.icon(@icon_name)
  166.     self.ox = self.bitmap.width / 2
  167.     self.oy = self.bitmap.height / 2
  168.     @active = false
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # ● 解放
  172.   #--------------------------------------------------------------------------
  173.   def dispose
  174.     if self.bitmap != nil
  175.       self.bitmap.dispose
  176.     end
  177.     super
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● フレーム更新
  181.   #--------------------------------------------------------------------------
  182.   def update
  183.     super
  184.     if @icon_name != @last_icon
  185.       @last_icon = @icon_name
  186.       self.bitmap = RPG::Cache.icon(@icon_name)
  187.     end
  188.     if @active
  189.       @count += 1
  190.       case Momo_IconCommand::SELECT_TYPE
  191.       when 0
  192.         icon_flash
  193.       when 1
  194.         icon_zoom
  195.       end
  196.       @count = 0 if @count == 20
  197.     else
  198.       icon_reset
  199.     end
  200.   end
  201.   def icon_flash
  202.     if @count % Momo_IconCommand::FLASH_INTERVAL == 0 or @count == 1
  203.       self.flash(Momo_IconCommand::FLASH_COLOR, Momo_IconCommand::FLASH_DURATION)
  204.     end
  205.   end
  206.   def icon_zoom
  207.     case @count
  208.     when 1..10
  209.       zoom = 1.0 + @count / 10.0
  210.     when 11..20
  211.       zoom = 2.0 - (@count - 10) / 10.0
  212.     end
  213.     self.zoom_x = zoom
  214.     self.zoom_y = zoom
  215.   end
  216.   def icon_reset
  217.     @count = 0
  218.     self.zoom_x = 1.0
  219.     self.zoom_y = 1.0
  220.   end
  221. end
  222. # コマンドネーム用スプライト
  223. class Sprite_Comm_Name < Sprite
  224.   attr_accessor :active
  225.   attr_accessor :name
  226.   attr_accessor :need_reset
  227.   #--------------------------------------------------------------------------
  228.   # ● オブジェクト初期化
  229.   #--------------------------------------------------------------------------
  230.   def initialize(viewport, name)
  231.     super(viewport)
  232.     @name = name
  233.     @last_name = nil
  234.     @count = 0
  235.     @x_plus = 0
  236.     @opa_plus = 0
  237.     @need_reset = false
  238.     @active = false
  239.     self.bitmap = Bitmap.new(160, 32)
  240.   end
  241.   #--------------------------------------------------------------------------
  242.   # ● 解放
  243.   #--------------------------------------------------------------------------
  244.   def dispose
  245.     if self.bitmap != nil
  246.       self.bitmap.dispose
  247.     end
  248.     super
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● フレーム更新
  252.   #--------------------------------------------------------------------------
  253.   def update
  254.     super
  255.     if @active
  256.       if need_reset?
  257.         @need_reset = false
  258.         @last_name = @name
  259.         text_reset
  260.       end
  261.       move_text if Momo_IconCommand::COM_NAME_MOVE
  262.     end
  263.   end
  264.   def move_text
  265.     @count += 1
  266.     @x_plus = [@count * 8, 80].min
  267.     self.y = 0
  268.     self.x = self.x - 300 - @x_plus
  269.     self.opacity = @count * 25
  270.   end
  271.   def text_reset
  272.     @count = 0
  273.     @x_plus = 0
  274.     self.bitmap.clear
  275.     self.bitmap.font.color = Momo_IconCommand::COM_NAME_COLOR
  276.     self.bitmap.draw_text(0, 0, 160, 32, @name)
  277.   end
  278.   def need_reset?
  279.     return (@name != @last_name or @need_reset)
  280.   end
  281. end
  282. class Scene_Battle
  283.   #--------------------------------------------------------------------------
  284.   # ● プレバトルフェーズ開始
  285.   #--------------------------------------------------------------------------
  286.   alias scene_battle_icon_command_start_phase1 start_phase1
  287.   def start_phase1
  288.     com1 = Momo_IconCommand::ATTACK_ICON_NAME
  289.     com2 = Momo_IconCommand::SKILL_ICON_NAME
  290.     com3 = Momo_IconCommand::GUARD_ICON_NAME
  291.     com4 = Momo_IconCommand::ITEM_ICON_NAME
  292.     @actor_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4])
  293.     @actor_command_window.y = 160
  294.     @actor_command_window.back_opacity = 160
  295.     $fff = 0
  296.     @actor_command_window.active = false
  297. #    @actor_command_window.visible = false
  298.     @actor_command_window.update
  299.     scene_battle_icon_command_start_phase1
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● アクターコマンドウィンドウのセットアップ
  303.   #--------------------------------------------------------------------------
  304.   alias scene_battle_icon_command_phase3_setup_command_window phase3_setup_command_window
  305.   def phase3_setup_command_window
  306.     scene_battle_icon_command_phase3_setup_command_window
  307.     # アクターコマンドウィンドウの位置を設定
  308.     @actor_command_window.x = command_window_actor_x(@actor_index)
  309.     @actor_command_window.y = command_window_actor_y(@actor_index)
  310.     @actor_command_window.need_reset
  311.   end
  312.   def command_window_actor_x(index)
  313.     $game_party.actors[index].screen_x + Momo_IconCommand::X_PLUS
  314.   end
  315.   def command_window_actor_y(index)
  316.     $game_party.actors[index].screen_y + Momo_IconCommand::Y_PLUS
  317.   end
  318. end
复制代码
回复

使用道具 举报

550

主题

9116

帖子

214748万

积分

超级版主

如同神一般的存在,腿神!拖后腿的神~~

Rank: 8Rank: 8

积分
2147483647
发表于 2010-3-23 20:22:44 | 显示全部楼层
发脚本请注意格式。
我就是你们的神,庶民们,追随我吧!跟着我一起拖后腿!
回复 支持 反对

使用道具 举报

6

主题

13

帖子

116

积分

③业余

积分
116
 楼主| 发表于 2010-3-24 15:36:09 | 显示全部楼层
算了 版主帮忙删帖吧
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2024-5-21 21:58 , Processed in 0.025852 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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