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

Project1

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

[已经过期] 图标式战斗菜单 如何在图标下加一个背景图?

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
73
在线时间
24 小时
注册时间
2008-8-4
帖子
113
跳转到指定楼层
1
发表于 2009-10-2 15:07:35 | 只看该作者 |只看大图 回帖奖励 |正序浏览 |阅读模式

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

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

x
我想把我的  做成就像下面空之轨迹的效果   不知道怎么加一个背景图
我的脚本

#==========================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==========================================================================

module Momo_IconCommand
  # 图标名称设定
  ATTACK_ICON_NAME = "菜单图标攻击" # 攻撃
  SKILL_ICON_NAME = "菜单图标技能"   # 特技
  GUARD_ICON_NAME = "菜单图标防御"  # 防御
  ITEM_ICON_NAME = "菜单图标道具"     # 物品
  ESCAPE_ICON_NAME = "菜单图标撤退"   # 逃跑
  # X坐标修正
  X_PLUS = - 20
  # Y坐标修正
  Y_PLUS = - 280
  # 选择时图标的动作
  # 0:静止 1:放大
  SELECT_TYPE = 0
  # 闪烁时光芒的颜色
  FLASH_COLOR = Color.new(255, 255, 255, 128)
  # 闪烁时间
  FLASH_DURATION = 10
  # 闪烁间隔
  FLASH_INTERVAL = 20
  # 是否写出文字的名称
  COM_NAME_DROW = false
  # 文字名称是否移动
  COM_NAME_MOVE = false
  # 文字内容
   ATTACK_NAME = ""   # 攻击
   SKILL_NAME = ""    # 仙术
   GUARD_NAME = ""    # 防御
   ITEM_NAME = ""     #物品
   ESCAPE_NAME = ""   #逃跑
  # 文字颜色
   COM_NAME_COLOR = Color.new(255, 255, 255, 255)
  # 文字坐标修正
   COM_NAME_X_PLUS = 0
   COM_NAME_Y_PLUS = 0
end


class Window_CommandIcon < Window_Selectable
  attr_accessor :last_index
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, commands)
    super(x, y, 32, 32)
    # ウィンドウスキンに空文字列を指定してウィンドウを描画しないようにする
    self.windowskin = RPG::Cache.windowskin("")
    self.z = 9999
   @item_max = commands.size #项目数
   @commands = commands #指令数
    @column_max = 1
    @index = 0
    @last_index = nil
    @name_sprite = nil
    @sprite = []
    refresh
  end
  def dispose
    super
    for sprite in @sprite
      sprite.dispose unless sprite.nil?
    end
    @name_sprite.dispose unless @name_sprite.nil?
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    @name_sprite.dispose unless @name_sprite.nil?
    for sprite in @sprite
      sprite.dispose unless sprite.nil?
    end
    @name_sprite = nil
    draw_com_name if Momo_IconCommand::COM_NAME_DROW
    @sprite = []
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● 項目の描画
  #--------------------------------------------------------------------------
  def draw_item(index)
    @sprite[index] = Sprite_Icon.new(nil, @commands[index])
    @sprite[index].z = self.z + 1
  end
  def draw_com_name
    @name_sprite = Sprite_Comm_Name.new(nil, get_com_name)
   
  end
  
  # 更新
  def update
    super
    icon_update
    com_name_update if Momo_IconCommand::COM_NAME_DROW
    if move_index?
      @last_index = self.index
    end
  end
  # アイコンの更新
  def icon_update
    for i in [email protected]   
      @sprite.active = (self.index == i)
      @sprite[0].x = 200
      @sprite[0].y = 150
      
      @sprite[1].x = 230
      @sprite[1].y = 190
      
      @sprite[2].x = 200
      @sprite[2].y = 230
      
      @sprite[3].x = 230
      @sprite[3].y = 270
      
      @sprite[4].x = 200
      @sprite[4].y = 310

      @sprite.z = (self.index == i) ? self.z + 2 : self.z + 1
      @sprite.visible = self.visible
      @sprite.update
    end
  end
  # コマンドネームの更新
  def com_name_update
    if move_index?
      @name_sprite.name = get_com_name
    end
    @name_sprite.x = self.x - 12 + Momo_IconCommand::COM_NAME_X_PLUS
    @name_sprite.y = self.y - 40 + Momo_IconCommand::COM_NAME_Y_PLUS
    @name_sprite.z = self.z + 1
    @name_sprite.active = self.active
    @name_sprite.visible = self.visible
    @name_sprite.update
  end
  def get_com_name
    make_name_set if @name_set.nil?
    name = @name_set[self.index]
    name = "" if name.nil?
    return name
  end
  def make_name_set
    @name_set = []
    @name_set[0] = Momo_IconCommand::ATTACK_NAME
    @name_set[1] = Momo_IconCommand::SKILL_NAME
    @name_set[2] = Momo_IconCommand::GUARD_NAME
    @name_set[3] = Momo_IconCommand::ITEM_NAME
    @name_set[4] = Momo_IconCommand::ESCAPE_ICON_NAME
  end
  def move_index?
    return self.index != @last_index
  end
  def need_reset
    @name_sprite.need_reset = true if Momo_IconCommand::COM_NAME_DROW
  end
end




# アイコン用スプライト
class Sprite_Icon < Sprite
  attr_accessor :active
  attr_accessor :icon_name
  #------------------------------------------------------------------------
  # ● オブジェクト初期化
  #------------------------------------------------------------------------
  def initialize(viewport, icon_name)
    super(viewport)
    @icon_name = icon_name
    @last_icon = @icon_name
    @count = 0
    self.bitmap = RPG::Cache.icon(@icon_name)
    self.ox = self.bitmap.width / 2
    self.oy = self.bitmap.height / 2
    @active = false
  end
  #------------------------------------------------------------------------
  # ● 解放
  #------------------------------------------------------------------------
  def dispose
    if self.bitmap != nil
      self.bitmap.dispose
    end
    super
  end
  #------------------------------------------------------------------------
  # ● フレーム更新
  #------------------------------------------------------------------------
  def update
    super
    if @icon_name != @last_icon
      @last_icon = @icon_name
      self.bitmap = RPG::Cache.icon(@icon_name)
    end
    if @active
      @count += 1
      case Momo_IconCommand::SELECT_TYPE
      when 0
        icon_flash
      when 1
        icon_zoom
      end
      @count = 0 if @count == 20
    else
      icon_reset
    end
  end
  def icon_flash
    if @count % Momo_IconCommand::FLASH_INTERVAL == 0 or @count == 2
      self.flash(Momo_IconCommand::FLASH_COLOR, Momo_IconCommand::FLASH_DURATION)
    end
  end
  def icon_zoom
    case @count
    when 1..10
      zoom = 1.0 + @count / 10.0
    when 11..20
      zoom = 2.0 - (@count - 10) / 10.0
    end
    self.zoom_x = zoom
    self.zoom_y = zoom
  end
  def icon_reset
    @count = 0
    self.zoom_x = 1.0
    self.zoom_y = 1.0
  end
end

# コマンドネーム用スプライト
class Sprite_Comm_Name < Sprite
  attr_accessor :active
  attr_accessor :name
  attr_accessor :need_reset
  #------------------------------------------------------------------------
  # ● オブジェクト初期化
  #------------------------------------------------------------------------
  def initialize(viewport, name)
    super(viewport)
    @name = name
    @last_name = nil
    @count = 0
    @x_plus = 0
    @opa_plus = 0
    @need_reset = false
    @active = false
    self.bitmap = Bitmap.new(160, 32)
  end
  #------------------------------------------------------------------------
  # ● 解放
  #------------------------------------------------------------------------
  def dispose
    if self.bitmap != nil
      self.bitmap.dispose
    end
    super
  end

  #------------------------------------------------------------------------
  # ● フレーム更新
  #------------------------------------------------------------------------
  def update
    super
    if @active
      if need_reset?
        @need_reset = false
        @last_name = @name
        text_reset
      end
      move_text if Momo_IconCommand::COM_NAME_MOVE
    end
  end
  def move_text
    @count += 1
    @x_plus = [@count * 8, 80].min
    self.x = self.x - 80 + @x_plus
    self.opacity = @count * 25
  end
  def text_reset
    @count = 0
    @x_plus = 0
    self.bitmap.clear
    self.bitmap.font.color = Momo_IconCommand::COM_NAME_COLOR
    self.bitmap.draw_text(0, 0, 160, 32, @name)
  end
  def need_reset?
    return (@name != @last_name or @need_reset)
  end
end

class Scene_Battle
  #------------------------------------------------------------------------
  # ● プレバトルフェーズ開始
  #------------------------------------------------------------------------
  alias scene_battle_icon_command_start_phase1 start_phase1
  def start_phase1
    com1 = Momo_IconCommand::ATTACK_ICON_NAME
    com2 = Momo_IconCommand::SKILL_ICON_NAME
    com3 = Momo_IconCommand::GUARD_ICON_NAME
    com4 = Momo_IconCommand::ITEM_ICON_NAME
    com5 = Momo_IconCommand::ESCAPE_ICON_NAME
    @actor_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4, com5])
    @actor_command_window.y = 128
    @actor_command_window.back_opacity = 160
    @actor_command_window.active = false
    @actor_command_window.visible = false
    @actor_command_window.update
    scene_battle_icon_command_start_phase1
  end
  #------------------------------------------------------------------------
  # ● アクターコマンドウィンドウのセットアップ
  #------------------------------------------------------------------------
  alias scene_battle_icon_command_phase3_setup_command_window phase3_setup_command_window
  def phase3_setup_command_window
    scene_battle_icon_command_phase3_setup_command_window
    # アクターコマンドウィンドウの位置を設定
    @actor_command_window.x = command_window_actor_x(@actor_index)
    @actor_command_window.y = command_window_actor_y(@actor_index)
    @actor_command_window.need_reset
  end
  def command_window_actor_x(index)
    $game_party.actors[index].screen_x + Momo_IconCommand::X_PLUS
  end
  def command_window_actor_y(index)
    $game_party.actors[index].screen_y + Momo_IconCommand::Y_PLUS
  end
end
#==========================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==========================================================================




谢谢大家····

未命名.jpg (83.32 KB, 下载次数: 6)

未命名.jpg

未命名2.jpg (19.28 KB, 下载次数: 0)

未命名2.jpg

Lv1.梦旅人

梦石
0
星屑
55
在线时间
5 小时
注册时间
2009-4-11
帖子
131
9
发表于 2009-10-23 18:26:26 | 只看该作者
在 def update  下 加入分歧
if  @actor_command_window.active == false
    @(图片的透明度) = 0
else
    @(图片的透明度) = 255
end

加入后看有没有用。。。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
73
在线时间
24 小时
注册时间
2008-8-4
帖子
113
8
 楼主| 发表于 2009-10-23 17:39:13 | 只看该作者
谢谢LS的大大  我用你的脚本试了  可以显示  
但是和 战斗 逃跑的选项图标 不是同时显示消失的呀·   也就是没人攻击  CP条走的时候  背景图还是存在·
回复 支持 反对

使用道具 举报

Lv1.梦旅人

风之塞尔达

梦石
0
星屑
50
在线时间
57 小时
注册时间
2005-10-22
帖子
2492

贵宾

7
发表于 2009-10-18 02:49:00 | 只看该作者

  1. module Momo_IconCommand
  2.   BACKGROUND_IMG_NAME = "Anglemenu4" # 在Pictures目录下的图像文件名
  3.   BACKGROUND_IMG_X = 200 # x 坐标
  4.   BACKGROUND_IMG_Y = 150 # y 坐标
  5. end


  6. class Window_CommandIcon < Window_Selectable
  7.   alias add_background_img_initialize initialize
  8.   def initialize(x, y, commands)
  9.     add_background_img_initialize(x, y, commands)
  10.     @backgroundImg = Sprite.new
  11.     @backgroundImg.x = Momo_IconCommand::BACKGROUND_IMG_X
  12.     @backgroundImg.y = Momo_IconCommand::BACKGROUND_IMG_Y
  13.     @backgroundImg.bitmap = RPG::Cache.picture(Momo_IconCommand::BACKGROUND_IMG_NAME)
  14.   end
  15.   alias add_background_img_dispose dispose
  16.   def dispose
  17.     add_background_img_dispose
  18.     @backgroundImg.dispose
  19.   end
  20.   alias add_background_img_update update
  21.   def update
  22.     add_background_img_update
  23.     @backgroundImg.update
  24.   end
  25. end
复制代码
在程序里延续塞尔达的传说, 在画板上勾勒塞尔达的轮廓!!
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
73
在线时间
24 小时
注册时间
2008-8-4
帖子
113
6
 楼主| 发表于 2009-10-17 14:06:22 | 只看该作者
  自顶一个  请大家帮忙
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
73
在线时间
24 小时
注册时间
2008-8-4
帖子
113
5
 楼主| 发表于 2009-10-3 18:04:15 | 只看该作者
{:4_84:} 要插在哪里呢···  之前我找到过一个图标脚本  附带了背景图  可是那个脚本我用着有问题就删了   
现在找不到了
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
73
在线时间
24 小时
注册时间
2008-8-4
帖子
113
4
 楼主| 发表于 2009-10-2 23:29:44 | 只看该作者
本帖最后由 zoeylau 于 2009-10-3 01:08 编辑

2# 风中承诺


这个··加在我那个脚本的哪一行呢? 我插了可是还没打就有图片了
回复 支持 反对

使用道具 举报

Lv3.寻梦者

小柯的徒弟

梦石
0
星屑
1500
在线时间
1157 小时
注册时间
2008-5-24
帖子
3085

贵宾

3
发表于 2009-10-2 22:00:13 | 只看该作者
在楼上的基础上,还要在Scene的loop~do后面(main的最后)加上@sprite.dispose。不然战斗结束后可会还在的哦~~
如果一开始看不到就@sprite.z = XXX 这样来调高优先度~~~
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
382
在线时间
235 小时
注册时间
2009-2-13
帖子
470
2
发表于 2009-10-2 17:53:32 | 只看该作者
那个语句……
picture = "Graphics/Pictures/ (图片名字)            "
     @sprite = Sprite.new
     @sprite.bitmap = Bitmap.new(picture)
那些人,那些事,等到明白了,也就无所谓了。
我博客:http://blog.sina.com.cn/gy963
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-7-21 05:13

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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