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

Project1

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

[已经过期] 如何修改,实现如图的功能?

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
25 小时
注册时间
2008-11-8
帖子
145
跳转到指定楼层
1
发表于 2011-1-23 01:32:08 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 fux2 于 2011-1-23 10:57 编辑




以下是代码:
  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.   ESCAPE_ICON_NAME="Escape"   # 逃跑
  10.   # X坐标修正
  11.   X_PLUS = -320
  12.   # Y坐标修正
  13.   Y_PLUS = -100
  14.   # 选择时图标的动作
  15.   # 0:静止 1:放大
  16.   SELECT_TYPE = false
  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.   ESCAPE_NAME="逃跑"   # 逃跑
  33.   # 文字颜色
  34.   COM_NAME_COLOR = Color.new(255, 255, 255, 255)
  35.   # 文字坐标修正
  36.   COM_NAME_X_PLUS = 0
  37.   COM_NAME_Y_PLUS = 0
  38. end

  39. class Window_CommandIcon < Window_Selectable
  40.   attr_accessor :last_index
  41.   #--------------------------------------------------------------------------
  42.   # ● オブジェクト初期化
  43.   #--------------------------------------------------------------------------
  44.   def initialize(x, y, commands)
  45.     super(x, y, 37, 37)
  46.     # ウィンドウスキンに空文字列を指定してウィンドウを描画しないようにする
  47.     self.windowskin = RPG::Cache.windowskin("")
  48.     @item_max = commands.size
  49.     @commands = commands
  50.     @column_max = commands.size
  51.     @index = 0
  52.     @last_index = nil
  53.     @name_sprite = nil
  54.     @sprite = []
  55.     refresh
  56.   end
  57.   def dispose
  58.     super
  59.     for sprite in @sprite
  60.       sprite.dispose unless sprite.nil?
  61.     end
  62.     @name_sprite.dispose unless @name_sprite.nil?
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # ● リフレッシュ
  66.   #--------------------------------------------------------------------------
  67.   def refresh
  68.     @name_sprite.dispose unless @name_sprite.nil?
  69.     for sprite in @sprite
  70.       sprite.dispose unless sprite.nil?
  71.     end
  72.     @name_sprite = nil
  73.     draw_com_name if Momo_IconCommand::COM_NAME_DROW
  74.     @sprite = []
  75.     for i in 0...@item_max
  76.       draw_item(i)
  77.     end
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 項目の描画
  81.   #--------------------------------------------------------------------------
  82.   def draw_item(index)
  83.     @sprite[index] = Sprite_Icon.new(nil, @commands[index])
  84.     @sprite[index].z = self.z + 1
  85.   end
  86.   def draw_com_name
  87.     @name_sprite = Sprite_Comm_Name.new(nil, get_com_name)
  88.    
  89.   end
  90.   
  91.   # 更新
  92.   def update
  93.     super
  94.   #--------------------------------------------------------------------------
  95.   
  96.    case index
  97.    when 0
  98.     if Input.repeat?(Input::DOWN)
  99.       $game_system.se_play($data_system.cursor_se)
  100.       @index = 3
  101.     end
  102.     if Input.repeat?(Input::RIGHT)
  103.       $game_system.se_play($data_system.cursor_se)
  104.       @index = 1
  105.       end
  106.     if Input.repeat?(Input::LEFT)
  107.       $game_system.se_play($data_system.cursor_se)
  108.       @index = 2
  109.     end
  110.       when 1
  111.         if Input.repeat?(Input::RIGHT)
  112.       $game_system.se_play($data_system.cursor_se)
  113.       @index = 2
  114.     end
  115.     if Input.repeat?(Input::LEFT)
  116.       $game_system.se_play($data_system.cursor_se)
  117.       @index = 0
  118.     end
  119.        when 2
  120.     if Input.repeat?(Input::LEFT)
  121.       $game_system.se_play($data_system.cursor_se)
  122.       @index = 1
  123.     end
  124.     if Input.repeat?(Input::RIGHT)
  125.       $game_system.se_play($data_system.cursor_se)
  126.       @index = 0
  127.     end
  128.         if Input.repeat?(Input::DOWN)
  129.       $game_system.se_play($data_system.cursor_se)
  130.       @index = 4
  131.     end
  132.         when 3
  133.     if Input.repeat?(Input::UP)
  134.       $game_system.se_play($data_system.cursor_se)
  135.       @index = 0
  136.     end
  137.     if Input.repeat?(Input::RIGHT)
  138.       $game_system.se_play($data_system.cursor_se)
  139.       @index = 4
  140.     end
  141.     if Input.repeat?(Input::LEFT)
  142.       $game_system.se_play($data_system.cursor_se)
  143.       @index = 4
  144.     end
  145.           when 4
  146.     if Input.repeat?(Input::UP)
  147.       $game_system.se_play($data_system.cursor_se)
  148.       @index = 2
  149.     end
  150.     if Input.repeat?(Input::RIGHT)
  151.       $game_system.se_play($data_system.cursor_se)
  152.       @index = 3
  153.     end
  154.     if Input.repeat?(Input::LEFT)
  155.       $game_system.se_play($data_system.cursor_se)
  156.       @index = 3
  157.     end
  158.     end
  159.    
  160.   #--------------------------------------------------------------------------

  161.     icon_update
  162.     com_name_update if Momo_IconCommand::COM_NAME_DROW
  163.     if move_index?
  164.       @last_index = self.index
  165.     end
  166.   end
  167.   # アイコンの更新
  168.   def icon_update
  169.     qx = 25
  170.     qy = 385
  171.     for i in [email][email protected][/email]
  172.       @sprite[i].active = (self.index == i)
  173.       @sprite[0].x = 350
  174.       @sprite[0].y = 205
  175.       @sprite[1].x = 350
  176.       @sprite[1].y = 205
  177.       @sprite[2].x = 350
  178.       @sprite[2].y = 205
  179.       @sprite[3].x = 350
  180.       @sprite[3].y = 205
  181.       @sprite[4].x = 350
  182.       @sprite[4].y = 205
  183.       #@sprite[i].x = self.x + i * 56
  184.       #@sprite[i].y = self.y + 0
  185.       @sprite[i].z = (self.index == i) ? self.z + 2 : self.z + 1
  186.       @sprite[i].visible = self.visible
  187.       @sprite[i].update
  188.     end
  189.   end
  190.   # コマンドネームの更新
  191.   def com_name_update
  192.     if move_index?
  193.       @name_sprite.name = get_com_name
  194.     end
  195.     @name_sprite.x = self.x - 12 + Momo_IconCommand::COM_NAME_X_PLUS
  196.     @name_sprite.y = self.y - 40 + Momo_IconCommand::COM_NAME_Y_PLUS
  197.     @name_sprite.z = self.z + 1
  198.     @name_sprite.active = self.active
  199.     @name_sprite.visible = self.visible
  200.     @name_sprite.update
  201.   end
  202.   def get_com_name
  203.     make_name_set if @name_set.nil?
  204.     name = @name_set[self.index]
  205.     name = "" if name.nil?
  206.     return name
  207.   end
  208.   def make_name_set
  209.     @name_set = []
  210.     @name_set[0] = Momo_IconCommand::ATTACK_NAME
  211.     @name_set[1] = Momo_IconCommand::SKILL_NAME
  212.     @name_set[2] = Momo_IconCommand::GUARD_NAME
  213.     @name_set[3] = Momo_IconCommand::ITEM_NAME
  214.     @name_set[4] = Momo_IconCommand::ESCAPE_NAME
  215.   end
  216.   def move_index?
  217.     return self.index != @last_index
  218.   end
  219.   def need_reset
  220.     @name_sprite.need_reset = true if Momo_IconCommand::COM_NAME_DROW
  221.   end
  222. end

  223. # アイコン用スプライト
  224. class Sprite_Icon < Sprite
  225.   attr_accessor :active
  226.   attr_accessor :icon_name
  227.   #--------------------------------------------------------------------------
  228.   # ● オブジェクト初期化
  229.   #--------------------------------------------------------------------------
  230.   def initialize(viewport, icon_name)
  231.     super(viewport)
  232.     @icon_name = icon_name
  233.     @last_icon = @icon_name
  234.     @count = 0
  235.     self.bitmap = RPG::Cache.icon(@icon_name)
  236.     self.ox = self.bitmap.width / 2
  237.     self.oy = self.bitmap.height / 2
  238.     @active = false
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # ● 解放
  242.   #--------------------------------------------------------------------------
  243.   def dispose
  244.     if self.bitmap != nil
  245.       self.bitmap.dispose
  246.     end
  247.     super
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● フレーム更新
  251.   #--------------------------------------------------------------------------
  252.   def update

  253.    

  254.    
  255.     super
  256.     if @icon_name != @last_icon
  257.       @last_icon = @icon_name
  258.       self.bitmap = RPG::Cache.icon(@icon_name)
  259.     end
  260.     if @active
  261.       @count += 1
  262.       case Momo_IconCommand::SELECT_TYPE
  263.       when 0
  264.         icon_flash
  265.       when 1
  266.         icon_zoom
  267.       end
  268.       @count = 0 if @count == 20
  269.     else
  270.       icon_reset
  271.     end
  272.   end
  273.   def icon_flash

  274.    
  275.    
  276.    
  277.     if @count % Momo_IconCommand::FLASH_INTERVAL == 0 or @count == 1
  278.       self.flash(Momo_IconCommand::FLASH_COLOR, Momo_IconCommand::FLASH_DURATION)
  279.     end
  280.   end
  281.   def icon_zoom
  282.     case @count
  283.     when 1..10
  284.       zoom = 1.0 + @count / 10.0
  285.     when 11..20
  286.       zoom = 2.0 - (@count - 10) / 10.0
  287.     end
  288.     self.zoom_x = zoom
  289.     self.zoom_y = zoom
  290.   end
  291.   def icon_reset
  292.     @count = 0
  293.     self.zoom_x = 1.0
  294.     self.zoom_y = 1.0
  295.   end
  296. end

  297. # コマンドネーム用スプライト
  298. class Sprite_Comm_Name < Sprite
  299.   attr_accessor :active
  300.   attr_accessor :name
  301.   attr_accessor :need_reset
  302.   #--------------------------------------------------------------------------
  303.   # ● オブジェクト初期化
  304.   #--------------------------------------------------------------------------
  305.   def initialize(viewport, name)
  306.     super(viewport)
  307.     @name = name
  308.     @last_name = nil
  309.     @count = 0
  310.     @x_plus = 0
  311.     @opa_plus = 0
  312.     @need_reset = false
  313.     @active = false
  314.     self.bitmap = Bitmap.new(160, 32)
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ● 解放
  318.   #--------------------------------------------------------------------------
  319.   def dispose
  320.     if self.bitmap != nil
  321.       self.bitmap.dispose
  322.     end
  323.     super
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● フレーム更新
  327.   #--------------------------------------------------------------------------
  328.   def update

  329.    

  330.    
  331.    
  332.     super
  333.     if @active
  334.       if need_reset?
  335.         @need_reset = false
  336.         @last_name = @name
  337.         text_reset
  338.       end
  339.       move_text if Momo_IconCommand::COM_NAME_MOVE
  340.     end
  341.   end
  342.   def move_text
  343.     @count += 1
  344.     @x_plus = [@count * 8, 80].min
  345.     self.y = 0
  346.     self.x = self.x - 300 - @x_plus
  347.     self.opacity = @count * 25
  348.   end
  349.   def text_reset
  350.     @count = 0
  351.     @x_plus = 0
  352.     self.bitmap.clear
  353.     self.bitmap.font.color = Momo_IconCommand::COM_NAME_COLOR
  354.     self.bitmap.draw_text(0, 0, 160, 32, @name)
  355.   end
  356.   def need_reset?
  357.     return (@name != @last_name or @need_reset)
  358.   end
  359. end

  360. class Scene_Battle
  361.   #--------------------------------------------------------------------------
  362.   # ● プレバトルフェーズ開始
  363.   #--------------------------------------------------------------------------
  364.   alias scene_battle_icon_command_start_phase1 start_phase1
  365.   def start_phase1
  366.     com1 = Momo_IconCommand::ATTACK_ICON_NAME
  367.     com2 = Momo_IconCommand::SKILL_ICON_NAME
  368.     com3 = Momo_IconCommand::GUARD_ICON_NAME
  369.     com4 = Momo_IconCommand::ITEM_ICON_NAME
  370.     com5 = Momo_IconCommand::ESCAPE_ICON_NAME
  371.     @actor_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4,com5])
  372.     @actor_command_window.y = 160
  373.     @actor_command_window.back_opacity = 160
  374.     $fff = 0
  375.     @actor_command_window.active = false
  376.     @actor_command_window.visible = false
  377.     @actor_command_window.update
  378.     scene_battle_icon_command_start_phase1
  379.   end
  380.   #--------------------------------------------------------------------------
  381.   # ● アクターコマンドウィンドウのセットアップ
  382.   #--------------------------------------------------------------------------
  383.   alias scene_battle_icon_command_phase3_setup_command_window phase3_setup_command_window
  384.   def phase3_setup_command_window
  385.     scene_battle_icon_command_phase3_setup_command_window
  386.     # アクターコマンドウィンドウの位置を設定
  387.     @actor_command_window.x = 1000
  388.     @actor_command_window.y = 1000
  389.     @actor_command_window.need_reset
  390.   end
  391.   def command_window_actor_x(index)
  392.     $game_party.actors[index].screen_x + Momo_IconCommand::X_PLUS
  393.   end
  394.   def command_window_actor_y(index)
  395.     $game_party.actors[index].screen_y + Momo_IconCommand::Y_PLUS
  396.   end
  397. end

  398. #==============================================================================
  399. #==============================================================================
复制代码

点评

下次记得用代码功能发代码  发表于 2011-1-23 10:58

Lv1.梦旅人

梦石
0
星屑
145
在线时间
698 小时
注册时间
2009-11-15
帖子
538
2
发表于 2011-1-23 07:27:49 | 只看该作者
本帖最后由 2719358 于 2011-1-23 07:49 编辑

先定义每个指令图的XY坐标,然后再下面显示一张图,刷新,战斗结束是释放就可以了,具体见F1
附代码:在这里更在坐标,大概是
  1. @sprite[0].x = 350
  2.       @sprite[0].y = 205
  3.       @sprite[1].x = 350
  4.       @sprite[1].y = 205
  5.       @sprite[2].x = 350
  6.       @sprite[2].y = 205
  7.       @sprite[3].x = 350
  8.       @sprite[3].y = 205
  9.       @sprite[4].x = 350
  10.       @sprite[4].y = 205
复制代码
显示图片再Spriteset_Battle的47行下面加上
  1. @XXX = Sprite.new
  2. @XXX.bitmap = Bitmap.new("***")
  3. @XXX.x = 0
  4. @XXX.y = 0
复制代码
在这里可以设置背景图的坐标,其中XXX是变量名,前后一点要一致***是图片地址
然后Spriteset_Battle的76行下加上[[email protected][/code]
最后在Spriteset_Battle的126行下加上
  1. @XXX.update
复制代码
就可以了
考上三级了!
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
25 小时
注册时间
2008-11-8
帖子
145
3
 楼主| 发表于 2011-1-23 10:17:16 | 只看该作者
不是这个问题,我用的脚本有问题:
  1. # 更新
  2.   def update
  3.     super
  4.   #--------------------------------------------------------------------------
  5.   
  6.    case index
  7.    when 0
  8.     if Input.repeat?(Input::DOWN)
  9.       $game_system.se_play($data_system.cursor_se)
  10.       @index = 3
  11.     end
  12.     if Input.repeat?(Input::RIGHT)
  13.       $game_system.se_play($data_system.cursor_se)
  14.       @index = 1
  15.       end
  16.     if Input.repeat?(Input::LEFT)
  17.       $game_system.se_play($data_system.cursor_se)
  18.       @index = 2
  19.     end
  20.       when 1
  21.         if Input.repeat?(Input::RIGHT)
  22.       $game_system.se_play($data_system.cursor_se)
  23.       @index = 2
  24.     end
  25.     if Input.repeat?(Input::LEFT)
  26.       $game_system.se_play($data_system.cursor_se)
  27.       @index = 0
  28.     end
  29.        when 2
  30.     if Input.repeat?(Input::LEFT)
  31.       $game_system.se_play($data_system.cursor_se)
  32.       @index = 1
  33.     end
  34.     if Input.repeat?(Input::RIGHT)
  35.       $game_system.se_play($data_system.cursor_se)
  36.       @index = 0
  37.     end
  38.         if Input.repeat?(Input::DOWN)
  39.       $game_system.se_play($data_system.cursor_se)
  40.       @index = 4
  41.     end
  42.         when 3
  43.     if Input.repeat?(Input::UP)
  44.       $game_system.se_play($data_system.cursor_se)
  45.       @index = 0
  46.     end
  47.     if Input.repeat?(Input::RIGHT)
  48.       $game_system.se_play($data_system.cursor_se)
  49.       @index = 4
  50.     end
  51.     if Input.repeat?(Input::LEFT)
  52.       $game_system.se_play($data_system.cursor_se)
  53.       @index = 4
  54.     end
  55.           when 4
  56.     if Input.repeat?(Input::UP)
  57.       $game_system.se_play($data_system.cursor_se)
  58.       @index = 2
  59.     end
  60.     if Input.repeat?(Input::RIGHT)
  61.       $game_system.se_play($data_system.cursor_se)
  62.       @index = 3
  63.     end
  64.     if Input.repeat?(Input::LEFT)
  65.       $game_system.se_play($data_system.cursor_se)
  66.       @index = 3
  67.     end
  68.     end
  69.    
复制代码
这段话,我修改了,可是按来按去都按不到技能那里
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-2-20 17:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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