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

Project1

 找回密码
 注册会员
搜索

仿新仙剑的战斗菜单问题

查看数: 2243 | 评论数: 2 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2010-8-1 17:25

正文摘要:

本帖最后由 仙芋 于 2010-8-3 13:04 编辑 我自己没有新仙剑的战斗菜单 所以到处拼拼的仿制了一个 可是用下来问题多多 希望有高手解答: 1) 我在特技说明只写了 "剑芒如雨直落,攻击敌方全体"      ...

回复

海老三 发表于 2010-9-23 20:06:31
  1. #==============================================================================
  2. #==============================================================================

  3. module Momo_IconCommand
  4.   # 图标名称设定
  5.   ATTACK_ICON_NAME = "Attack" # 攻撃
  6.   SKILL_ICON_NAME = "Skill"   # 特技
  7.   GUARD_ICON_NAME = "Guard"  # 防御
  8.   ITEM_ICON_NAME = "Thing"     # 物品
  9.   ITEM_ICON_NAME2 = "Thing2"
  10.   # X坐标修正
  11.   X_PLUS = -320
  12.   # Y坐标修正
  13.   Y_PLUS = -100
  14.   # 选择时图标的动作
  15.   # 0:静止 1:放大
  16.   SELECT_TYPE = 0
  17.   # 闪烁时光芒的颜色
  18.   FLASH_COLOR = Color.new(255, 255, 255, 128)
  19.   # 闪烁时间
  20.   FLASH_DURATION = 10
  21.   # 闪烁间隔
  22.   FLASH_INTERVAL = 20
  23.   # 是否写出文字的名称
  24.   COM_NAME_DROW = false
  25.   # 文字名称是否移动
  26.   COM_NAME_MOVE = false
  27.   # 文字内容
  28.   ATTACK_NAME = "攻击"    # 攻击
  29.   SKILL_NAME = "特技"   # 特技
  30.   GUARD_NAME = "防御"     # 防御
  31.   ITEM_NAME = "物品"  # 物品
  32.   # 文字颜色
  33.   COM_NAME_COLOR = Color.new(255, 255, 255, 255)
  34.   # 文字坐标修正
  35.   COM_NAME_X_PLUS = 0
  36.   COM_NAME_Y_PLUS = 0
  37. end

  38. class Window_CommandIcon < Window_Selectable2
  39.   attr_accessor :last_index
  40.   #--------------------------------------------------------------------------
  41.   # ● オブジェクト初期化
  42.   #--------------------------------------------------------------------------
  43.   def initialize(x, y, commands)
  44.     super(x, y, 37, 37)
  45.     # ウィンドウスキンに空文字列を指定してウィンドウを描画しないようにする
  46.     self.windowskin = RPG::Cache.windowskin("")
  47.     @item_max = commands.size
  48.     @commands = commands
  49.     @column_max = commands.size
  50.     @index = 0
  51.     @last_index = nil
  52.     @name_sprite = nil
  53.     @sprite = []
  54.     refresh
  55.   end
  56.   def dispose
  57.     super
  58.     for sprite in @sprite
  59.       sprite.dispose unless sprite.nil?
  60.     end
  61.     @name_sprite.dispose unless @name_sprite.nil?
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● リフレッシュ
  65.   #--------------------------------------------------------------------------
  66.   def refresh
  67.     @name_sprite.dispose unless @name_sprite.nil?
  68.     for sprite in @sprite
  69.       sprite.dispose unless sprite.nil?
  70.     end
  71.     @name_sprite = nil
  72.     draw_com_name if Momo_IconCommand::COM_NAME_DROW
  73.     @sprite = []
  74.     for i in 0...@item_max
  75.       draw_item(i)
  76.     end
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● 項目の描画
  80.   #--------------------------------------------------------------------------
  81.   def draw_item(index)
  82.     @sprite[index] = Sprite_Icon.new(nil, @commands[index])
  83.     @sprite[index].z = self.z + 1
  84.   end
  85.   def draw_com_name
  86.     @name_sprite = Sprite_Comm_Name.new(nil, get_com_name)
  87.    
  88.   end
  89.   
  90.   # 更新
  91.   def update
  92.       
  93.    



  94.    
  95.    
  96.    
  97.     super
  98.     icon_update
  99.     com_name_update if Momo_IconCommand::COM_NAME_DROW
  100.     if move_index?
  101.       @last_index = self.index
  102.     end
  103.   end
  104.   # アイコンの更新
  105.   def icon_update
  106.     qx = 25
  107.     qy = 385
  108.     for i in [email protected]
  109.       @sprite[i].active = (self.index == i)
  110.       @sprite[0].x = 40 +qx
  111.       @sprite[0].y = -15 +qy
  112.       @sprite[1].x = 0 + qx
  113.       @sprite[1].y = 23 + qy
  114.       @sprite[2].x = 40 + qx
  115.       @sprite[2].y = 59 + qy
  116.       @sprite[3].x = 81 + qx
  117.       @sprite[3].y = 23 + qy
  118.       #@sprite[i].x = self.x + i * 56
  119.       #@sprite[i].y = self.y + 0
  120.       @sprite[i].z = (self.index == i) ? self.z + 2 : self.z + 1
  121.       @sprite[i].visible = self.visible
  122.       @sprite[i].update
  123.     end
  124.   end
  125.   # コマンドネームの更新
  126.   def com_name_update
  127.     if move_index?
  128.       @name_sprite.name = get_com_name
  129.     end
  130.     @name_sprite.x = self.x - 12 + Momo_IconCommand::COM_NAME_X_PLUS
  131.     @name_sprite.y = self.y - 40 + Momo_IconCommand::COM_NAME_Y_PLUS
  132.     @name_sprite.z = self.z + 1
  133.     @name_sprite.active = self.active
  134.     @name_sprite.visible = self.visible
  135.     @name_sprite.update
  136.   end
  137.   def get_com_name
  138.     make_name_set if @name_set.nil?
  139.     name = @name_set[self.index]
  140.     name = "" if name.nil?
  141.     return name
  142.   end
  143.   def make_name_set
  144.     @name_set = []
  145.     @name_set[0] = Momo_IconCommand::ATTACK_NAME
  146.     @name_set[1] = Momo_IconCommand::SKILL_NAME
  147.     @name_set[2] = Momo_IconCommand::GUARD_NAME
  148.     @name_set[3] = Momo_IconCommand::ITEM_NAME
  149.   end
  150.   def move_index?
  151.     return self.index != @last_index
  152.   end
  153.   def need_reset
  154.     @name_sprite.need_reset = true if Momo_IconCommand::COM_NAME_DROW
  155.   end
  156. end

  157. # アイコン用スプライト
  158. class Sprite_Icon < Sprite
  159.   attr_accessor :active
  160.   attr_accessor :icon_name
  161.   #--------------------------------------------------------------------------
  162.   # ● オブジェクト初期化
  163.   #--------------------------------------------------------------------------
  164.   def initialize(viewport, icon_name)
  165.     super(viewport)
  166.     @icon_name = icon_name
  167.     @last_icon = @icon_name
  168.     @count = 0
  169.     self.bitmap = RPG::Cache.icon(@icon_name)
  170.     self.ox = self.bitmap.width / 2
  171.     self.oy = self.bitmap.height / 2
  172.     @active = false
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # ● 解放
  176.   #--------------------------------------------------------------------------
  177.   def dispose
  178.     if self.bitmap != nil
  179.       self.bitmap.dispose
  180.     end
  181.     super
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● フレーム更新
  185.   #--------------------------------------------------------------------------
  186.   def update

  187.    

  188.    
  189.     super
  190.     if @icon_name != @last_icon
  191.       @last_icon = @icon_name
  192.       self.bitmap = RPG::Cache.icon(@icon_name)
  193.     end
  194.     if @active
  195.       @count += 1
  196.       case Momo_IconCommand::SELECT_TYPE
  197.       when 0
  198.         icon_flash
  199.       when 1
  200.         icon_zoom
  201.       end
  202.       @count = 0 if @count == 20
  203.     else
  204.       icon_reset
  205.     end
  206.   end
  207.   def icon_flash

  208.    
  209.    
  210.    
  211.     if @count % Momo_IconCommand::FLASH_INTERVAL == 0 or @count == 1
  212.       self.flash(Momo_IconCommand::FLASH_COLOR, Momo_IconCommand::FLASH_DURATION)
  213.     end
  214.   end
  215.   def icon_zoom
  216.     case @count
  217.     when 1..10
  218.       zoom = 1.0 + @count / 10.0
  219.     when 11..20
  220.       zoom = 2.0 - (@count - 10) / 10.0
  221.     end
  222.     self.zoom_x = zoom
  223.     self.zoom_y = zoom
  224.   end
  225.   def icon_reset
  226.     @count = 0
  227.     self.zoom_x = 1.0
  228.     self.zoom_y = 1.0
  229.   end
  230. end

  231. # コマンドネーム用スプライト
  232. class Sprite_Comm_Name < Sprite
  233.   attr_accessor :active
  234.   attr_accessor :name
  235.   attr_accessor :need_reset
  236.   #--------------------------------------------------------------------------
  237.   # ● オブジェクト初期化
  238.   #--------------------------------------------------------------------------
  239.   def initialize(viewport, name)
  240.     super(viewport)
  241.     @name = name
  242.     @last_name = nil
  243.     @count = 0
  244.     @x_plus = 0
  245.     @opa_plus = 0
  246.     @need_reset = false
  247.     @active = false
  248.     self.bitmap = Bitmap.new(160, 32)
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● 解放
  252.   #--------------------------------------------------------------------------
  253.   def dispose
  254.     if self.bitmap != nil
  255.       self.bitmap.dispose
  256.     end
  257.     super
  258.   end
  259.   #--------------------------------------------------------------------------
  260.   # ● フレーム更新
  261.   #--------------------------------------------------------------------------
  262.   def update

  263.    

  264.    
  265.    
  266.     super
  267.     if @active
  268.       if need_reset?
  269.         @need_reset = false
  270.         @last_name = @name
  271.         text_reset
  272.       end
  273.       move_text if Momo_IconCommand::COM_NAME_MOVE
  274.     end
  275.   end
  276.   def move_text
  277.     @count += 1
  278.     @x_plus = [@count * 8, 80].min
  279.     self.y = 0
  280.     self.x = self.x - 300 - @x_plus
  281.     self.opacity = @count * 25
  282.   end
  283.   def text_reset
  284.     @count = 0
  285.     @x_plus = 0
  286.     self.bitmap.clear
  287.     self.bitmap.font.color = Momo_IconCommand::COM_NAME_COLOR
  288.     self.bitmap.draw_text(0, 0, 160, 32, @name)
  289.   end
  290.   def need_reset?
  291.     return (@name != @last_name or @need_reset)
  292.   end
  293. end

  294. class Scene_Battle
  295.   #--------------------------------------------------------------------------
  296.   # ● プレバトルフェーズ開始
  297.   #--------------------------------------------------------------------------
  298.   alias scene_battle_icon_command_start_phase1 start_phase1
  299.   def start_phase1
  300.     com1 = Momo_IconCommand::ATTACK_ICON_NAME
  301.     com2 = Momo_IconCommand::SKILL_ICON_NAME
  302.     com3 = Momo_IconCommand::GUARD_ICON_NAME
  303.     if $game_party.actors.size > 1
  304.       com4 = Momo_IconCommand::ITEM_ICON_NAME
  305.     else
  306.       com4 = Momo_IconCommand::ITEM_ICON_NAME2
  307.     end
  308.     @actor_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4])
  309.     @actor_command_window.y = 160
  310.     @actor_command_window.back_opacity = 160
  311.     if Input.repeat?(Input::UP)
  312.       com1 = Momo_IconCommand::ATTACK_ICON_NAME
  313.     end
  314.     if Input.repeat?(Input::DOWN)
  315.       com3 = Momo_IconCommand::GUARD_ICON_NAME
  316.     end
  317.     if Input.repeat?(Input::LEFT)
  318.       com2 = Momo_IconCommand::SKILL_ICON_NAME
  319.     end
  320.     if Input.repeat?(Input::RIGHT)
  321.       com4 = Momo_IconCommand::ITEM_ICON_NAME
  322.     end
  323.    
  324.       
  325.     $fff = 0
  326.     @actor_command_window.active = false
  327. #    @actor_command_window.visible = false
  328.     @actor_command_window.update
  329.     scene_battle_icon_command_start_phase1
  330.   end
  331.   #--------------------------------------------------------------------------
  332.   # ● アクターコマンドウィンドウのセットアップ
  333.   #--------------------------------------------------------------------------
  334.   alias scene_battle_icon_command_phase3_setup_command_window phase3_setup_command_window
  335.   def phase3_setup_command_window
  336.     scene_battle_icon_command_phase3_setup_command_window
  337.     # アクターコマンドウィンドウの位置を設定
  338.     @actor_command_window.x = 1000
  339.     @actor_command_window.y = 1000
  340.     @actor_command_window.need_reset
  341.   end
  342.   def command_window_actor_x(index)
  343.     $game_party.actors[index].screen_x + Momo_IconCommand::X_PLUS
  344.   end
  345.   def command_window_actor_y(index)
  346.     $game_party.actors[index].screen_y + Momo_IconCommand::Y_PLUS
  347.   end
  348. end

  349. #==============================================================================
  350. #==============================================================================
复制代码
貌似我是用的这个脚本,LZ自己来校正一下吧,也可能是有冲突。

评分

参与人数 1星屑 -60 收起 理由
六祈 -60 挖坟有奖励

查看全部评分

q626314 发表于 2010-8-1 19:46:31
提示: 作者被禁止或删除 内容自动屏蔽
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-12-24 00:30

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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