Project1

标题: 将图标战斗菜单按仙剑模式排列如何做? [打印本页]

作者: 5838016    时间: 2008-2-3 01:44
提示: 作者被禁止或删除 内容自动屏蔽
作者: 5838016    时间: 2008-2-3 03:07
提示: 作者被禁止或删除 内容自动屏蔽
作者: 天圣的马甲    时间: 2008-2-3 03:11
把《灵儿续传》的同样的脚本拽出来给你,你看着调整一下,对比一下不同的地方就知道坐标应该改哪里了。
  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.   # X坐标修正
  10.   X_PLUS = -320
  11.   # Y坐标修正
  12.   Y_PLUS = -100
  13.   # 选择时图标的动作
  14.   # 0:静止 1:放大
  15.   SELECT_TYPE = 0
  16.   # 闪烁时光芒的颜色
  17.   FLASH_COLOR = Color.new(255, 255, 255, 128)
  18.   # 闪烁时间
  19.   FLASH_DURATION = 10
  20.   # 闪烁间隔
  21.   FLASH_INTERVAL = 20
  22.   # 是否写出文字的名称
  23.   COM_NAME_DROW = false
  24.   # 文字名称是否移动
  25.   COM_NAME_MOVE = false
  26.   # 文字内容
  27.   ATTACK_NAME = "攻击"    # 攻击
  28.   SKILL_NAME = "特技"   # 特技
  29.   GUARD_NAME = "防御"     # 防御
  30.   ITEM_NAME = "物品"  # 物品
  31.   # 文字颜色
  32.   COM_NAME_COLOR = Color.new(255, 255, 255, 255)
  33.   # 文字坐标修正
  34.   COM_NAME_X_PLUS = 0
  35.   COM_NAME_Y_PLUS = 0
  36. end

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



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

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

  186.    

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

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

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

  262.    

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

  293. class Scene_Battle
  294.   #--------------------------------------------------------------------------
  295.   # ● プレバトルフェーズ開始
  296.   #--------------------------------------------------------------------------
  297.   alias scene_battle_icon_command_start_phase1 start_phase1
  298.   def start_phase1
  299.     com1 = Momo_IconCommand::ATTACK_ICON_NAME
  300.     com2 = Momo_IconCommand::SKILL_ICON_NAME
  301.     com3 = Momo_IconCommand::GUARD_ICON_NAME
  302.     com4 = Momo_IconCommand::ITEM_ICON_NAME
  303.     @actor_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4])
  304.     @actor_command_window.y = 160
  305.     @actor_command_window.back_opacity = 160
  306.     $fff = 0
  307.     @actor_command_window.active = false
  308. #    @actor_command_window.visible = false
  309.     @actor_command_window.update
  310.     scene_battle_icon_command_start_phase1
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● アクターコマンドウィンドウのセットアップ
  314.   #--------------------------------------------------------------------------
  315.   alias scene_battle_icon_command_phase3_setup_command_window phase3_setup_command_window
  316.   def phase3_setup_command_window
  317.     scene_battle_icon_command_phase3_setup_command_window
  318.     # アクターコマンドウィンドウの位置を設定
  319.     @actor_command_window.x = 1000
  320.     @actor_command_window.y = 1000
  321.     @actor_command_window.need_reset
  322.   end
  323.   def command_window_actor_x(index)
  324.     $game_party.actors[index].screen_x + Momo_IconCommand::X_PLUS
  325.   end
  326.   def command_window_actor_y(index)
  327.     $game_party.actors[index].screen_y + Momo_IconCommand::Y_PLUS
  328.   end
  329. end

  330. #==============================================================================
  331. #==============================================================================
复制代码

[LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1