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

Project1

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

[有事请教] 求教 如何改动敌人状态显示位置

[复制链接]

Lv1.梦旅人

梦石
0
星屑
49
在线时间
2 小时
注册时间
2024-9-14
帖子
4
跳转到指定楼层
1
发表于 前天 12:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
如题 找了个敌人状态显示插件
但是有些敌人图太大了看不到(显示在头顶上)
求教如何挪一下位置让它在脚底下显示

RUBY 代码复制
  1. #==============================================================================
  2. #  ■エネミーの状態を表示 for RGSS3 Ver0.80-α
  3. # □作成者 kure
  4. #==============================================================================
  5. $kure_base_script = {} if $kure_base_script == nil
  6. $kure_base_script[:InfoBar] = 100
  7. p "エネミーの情報表示"
  8. module KURE
  9.   module InfoBar
  10.     #初期設定(変更しない事)-----------------------------------------------------
  11.     COLOR = []
  12.  
  13.     #表示色(IDによって割り当てが決まっています。)
  14.       #バーの背景色(ID0)
  15.       COLOR[0] = Color.new(32 ,32, 64, 255)
  16.  
  17.       #HPバーの色(ID1,ID2)
  18.       COLOR[1] = Color.new(224 ,128, 64, 255)
  19.       COLOR[2] = Color.new(240 ,192, 64, 255)
  20.  
  21.   end
  22. end
  23.  
  24. #==============================================================================
  25. # ■ RPG::Enemy(追加定義)
  26. #==============================================================================
  27. class RPG::Enemy < RPG::BaseItem
  28.   #--------------------------------------------------------------------------
  29.   # ☆ バーの表示幅の定義(追加定義)
  30.   #--------------------------------------------------------------------------  
  31.   def infobar_width
  32.     @note.match(/<情報表示幅\s?(\d+)\s?>/)
  33.     return 100 unless $1
  34.     return $1.to_i
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ☆ バーの表示幅の定義(追加定義)
  38.   #--------------------------------------------------------------------------  
  39.   def infobar_visible?
  40.     return false if @note.include?("<情報非表示>")
  41.     return true
  42.   end
  43. end
  44.  
  45. #==============================================================================
  46. # ■ Game_Enemy
  47. #==============================================================================
  48. class Game_Enemy < Game_Battler
  49.   #--------------------------------------------------------------------------
  50.   # ☆ バーの表示幅の定義(追加定義)
  51.   #--------------------------------------------------------------------------  
  52.   def infobar_width
  53.     return enemy.infobar_width
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ☆ バーの表示幅の定義(追加定義)
  57.   #--------------------------------------------------------------------------  
  58.   def infobar_visible?
  59.     return enemy.infobar_visible?
  60.   end
  61. end
  62.  
  63. #==============================================================================
  64. # ■ Spriteset_Battle
  65. #==============================================================================
  66. class Spriteset_Battle
  67.   #--------------------------------------------------------------------------
  68.   # ● 敵キャラスプライトの作成(エイリアス再定義)
  69.   #--------------------------------------------------------------------------
  70.   alias k_basescript_before_create_enemies create_enemies
  71.   def create_enemies
  72.     k_basescript_before_create_enemies
  73.     @enemy_info_bar = $game_troop.members.reverse.collect do |enemy|
  74.       Sprite_Infobar.new(@viewport1, enemy)
  75.     end
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # ● 敵キャラスプライトの更新(エイリアス再定義)
  79.   #--------------------------------------------------------------------------
  80.   alias k_basescript_before_update_enemies update_enemies
  81.   def update_enemies
  82.     k_basescript_before_update_enemies
  83.     @enemy_info_bar.each {|sprite| sprite.update }
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # ● 敵キャラスプライトの解放(エイリアス再定義)
  87.   #--------------------------------------------------------------------------
  88.   alias k_basescript_before_dispose_enemies dispose_enemies
  89.   def dispose_enemies
  90.     k_basescript_before_dispose_enemies
  91.     @enemy_info_bar.each {|sprite| sprite.dispose }
  92.   end
  93. end
  94.  
  95. #==============================================================================
  96. # ■ Sprite_Infobar
  97. #==============================================================================
  98. class Sprite_Infobar < Sprite_Base
  99.   #--------------------------------------------------------------------------
  100.   # ● 公開インスタンス変数
  101.   #--------------------------------------------------------------------------
  102.   attr_accessor :battler
  103.   #--------------------------------------------------------------------------
  104.   # ● オブジェクト初期化
  105.   #--------------------------------------------------------------------------
  106.   def initialize(viewport, battler = nil)
  107.     super(viewport)
  108.     @battler = battler
  109.     @fill_w = nil
  110.     @bitmap_data = Cache.battler(battler.battler_name, battler.battler_hue)
  111.     @state = battler.states
  112.     @icon_set = Cache.system("Iconset")
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ● フレーム更新
  116.   #--------------------------------------------------------------------------
  117.   def update
  118.     super
  119.     if @battler
  120.       @use_sprite = @battler.use_sprite?
  121.       if @use_sprite
  122.         update_bitmap
  123.         update_origin
  124.         update_position
  125.       end
  126.     else
  127.       self.bitmap = nil
  128.     end
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ● 解放
  132.   #--------------------------------------------------------------------------
  133.   def dispose
  134.     bitmap.dispose if bitmap
  135.     super
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● 転送元ビットマップの更新
  139.   #--------------------------------------------------------------------------
  140.   def update_bitmap
  141.     fill_w = @battler.infobar_width * (@battler.hp.to_f / @battler.mhp)
  142.     state = battler.states
  143.     if @fill_w != fill_w or @state != state
  144.       @fill_w = fill_w
  145.       @state = state
  146.  
  147.       width = @battler.infobar_width + 4
  148.  
  149.       new_bitmap = Bitmap.new(width, 35)
  150.       @state.each_with_index {|state, index|
  151.         next if 24 * (index + 1) > new_bitmap.width
  152.         rect = Rect.new(state.icon_index % 16 * 24, state.icon_index / 16 * 24, 24, 24)
  153.         new_bitmap.blt(24 * index, 0, @icon_set, rect, 255)
  154.       }
  155.       #new_bitmap.fill_rect(0, 25, width, 10, color(0))
  156.       #new_bitmap.gradient_fill_rect(2, 27, fill_w, 6, color(1), color(2))
  157.  
  158.       self.bitmap = new_bitmap
  159.       init_visibility
  160.  
  161.       self.opacity = 0 unless @battler.infobar_visible?
  162.     end
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 可視状態の初期化
  166.   #--------------------------------------------------------------------------
  167.   def init_visibility
  168.     @battler_visible = @battler.alive?
  169.     self.opacity = 0 unless @battler_visible
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● 文字色取得
  173.   #--------------------------------------------------------------------------
  174.   def color(num)
  175.     return KURE::InfoBar::COLOR[num]
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ● 原点の更新
  179.   #--------------------------------------------------------------------------
  180.   def update_origin
  181.     if bitmap
  182.       self.ox = bitmap.width / 5
  183.       self.oy = bitmap.height
  184.     end
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # ● 位置の更新
  188.   #--------------------------------------------------------------------------
  189.   def update_position
  190.     self.x = @battler.screen_x
  191.     self.y = @battler.screen_y - @bitmap_data.height
  192.     self.z = @battler.screen_z + 10
  193.   end
  194. end

Lv5.捕梦者

梦石
0
星屑
38742
在线时间
5703 小时
注册时间
2006-11-10
帖子
6609
2
发表于 前天 18:36 | 只看该作者
191行改成,  self.y = @battler.screen_y + 10086

要离脚底多远自己调整10086这个数字
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-24 11:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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