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

Project1

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

[已经过期] 敌人名字显示的好奇怪?请大神帮解决下?在线等!

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
207 小时
注册时间
2014-8-16
帖子
132
跳转到指定楼层
1
发表于 2015-9-25 20:41:35 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 a107480098 于 2015-9-25 21:29 编辑

敌人名字显示的好奇怪?敌人名字显示在了右边,请大神帮解决下?看图:

脚本:
RUBY 代码复制
  1. #==============================================================================
  2. module PLAN_HPSP_DRAW
  3.   FONT_NAME         = ["宋体"]    # フォント
  4.   FONT_SIZE         =  12                               # フォントサイズ
  5.   FONT_BOLD         = true                              # 太字
  6.   FONT_ITALIC       = false #true                              # 斜体
  7.  
  8.   DRAW_NAME         = true                              # 名前の描画
  9.   DRAW_HP           = false                             # HP の描画
  10.   DRAW_SP           = false                              # SP の描画
  11.  
  12.   DRAW_WIDTH        = 80                              # 描画幅
  13.   DRAW_HEIGHT       = 3 * 32                            # 描画高さ
  14.   DRAW_SPACE        = 0                              # 行間
  15.   DRAW_Y            = 24                               # Y 座標修正値
  16. end
  17.  
  18.  
  19. #==============================================================================
  20. # ■ Sprite_Battler
  21. #==============================================================================
  22.  
  23. class Sprite_Battler < RPG::Sprite
  24.   #--------------------------------------------------------------------------
  25.   # ● オブジェクト初期化
  26.   #--------------------------------------------------------------------------
  27.   alias plan_enemy_hpsp_draw_initialize initialize
  28.   def initialize(viewport, battler = nil)
  29.     # 元のメソッドに戻す
  30.     plan_enemy_hpsp_draw_initialize(viewport, battler)
  31.     # エネミーの場合
  32.     if @battler.is_a?(Game_Enemy)
  33.       width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  34.       height = PLAN_HPSP_DRAW::DRAW_HEIGHT + 32
  35.       x = @battler.screen_x - width / 2
  36.       y = @battler.screen_y - height + 32 + PLAN_HPSP_DRAW::DRAW_Y
  37.       @enemy_hpsp_window = Window_Base.new(x, y, width, height)
  38.       @enemy_hpsp_window.contents = Bitmap.new(width - 32, height - 32)
  39.       @enemy_hpsp_window.contents.font.name = PLAN_HPSP_DRAW::FONT_NAME
  40.       @enemy_hpsp_window.contents.font.size = PLAN_HPSP_DRAW::FONT_SIZE
  41.       @enemy_hpsp_window.contents.font.bold = PLAN_HPSP_DRAW::FONT_BOLD
  42.       @enemy_hpsp_window.contents.font.italic = PLAN_HPSP_DRAW::FONT_ITALIC
  43.       y = 0
  44.       @old_enemy_hpsp = []
  45.       one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
  46.       if PLAN_HPSP_DRAW::DRAW_NAME
  47.         @enemy_hpsp_window.draw_actor_name(@battler, 0, y, width - 32)
  48.         y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  49.         @old_enemy_hpsp.push(@battler.name)
  50.       end
  51.       if PLAN_HPSP_DRAW::DRAW_HP
  52.         @enemy_hpsp_window.draw_actor_hp(@battler, 0, y, width - 32)
  53.         y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  54.         @old_enemy_hpsp.push(@battler.hp)
  55.       end
  56.       if PLAN_HPSP_DRAW::DRAW_SP
  57.         @enemy_hpsp_window.draw_actor_sp(@battler, 0, y, width - 32)
  58.         @old_enemy_hpsp.push(@battler.sp)
  59.       end
  60.       @enemy_hpsp_window.opacity = 0
  61.       @enemy_hpsp_window.contents_opacity = 0
  62.       @enemy_hpsp_window.z = -2
  63.     end
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 解放
  67.   #--------------------------------------------------------------------------
  68.   alias plan_enemy_hpsp_draw_dispose dispose
  69.   def dispose
  70.     # エネミーの場合
  71.     if @battler.is_a?(Game_Enemy)
  72.       @enemy_hpsp_window.dispose
  73.     end
  74.     # 元のメソッドに戻す
  75.     plan_enemy_hpsp_draw_dispose
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # ● フレーム更新
  79.   #--------------------------------------------------------------------------
  80.   alias plan_enemy_hpsp_draw_update update
  81.   def update
  82.     # 元のメソッドに戻す
  83.     plan_enemy_hpsp_draw_update
  84.     # エネミーの場合
  85.     if @battler.is_a?(Game_Enemy)
  86.       @enemy_hpsp_window.visible = @battler_visible
  87.     # スプライトの座標を設定
  88.       width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  89.       @enemy_hpsp_window.x = self.x - width / 2 + 5
  90.       @enemy_hpsp_window.y = self.y - 40
  91.       @now_enemy_hpsp = []
  92.       if PLAN_HPSP_DRAW::DRAW_NAME
  93.         @now_enemy_hpsp.push(@battler.name)
  94.       end
  95.       if PLAN_HPSP_DRAW::DRAW_HP
  96.         @now_enemy_hpsp.push(@battler.hp)
  97.       end
  98.       if PLAN_HPSP_DRAW::DRAW_SP
  99.         @now_enemy_hpsp.push(@battler.sp)
  100.       end
  101.       if @old_enemy_hpsp != @now_enemy_hpsp and $game_temp.enemy_hpsp_refresh
  102.         @old_enemy_hpsp = @now_enemy_hpsp
  103.         @enemy_hpsp_window.contents.clear
  104.         y = 0
  105.         width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  106.         one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
  107.         if PLAN_HPSP_DRAW::DRAW_NAME
  108.           @enemy_hpsp_window.draw_actor_name(@battler, 0, y, width - 32)
  109.           y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  110.         end
  111.         if PLAN_HPSP_DRAW::DRAW_HP
  112.           @enemy_hpsp_window.draw_actor_hp(@battler, 0, y, width - 32)
  113.           y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  114.         end
  115.         if PLAN_HPSP_DRAW::DRAW_SP
  116.           @enemy_hpsp_window.draw_actor_sp(@battler, 0, y, width - 32)
  117.         end
  118.         Graphics.frame_reset
  119.       end
  120.     end
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● visible の設定
  124.   #--------------------------------------------------------------------------
  125.   if !method_defined?("plan_enemy_hpsp_draw_visible=")
  126.     alias plan_enemy_hpsp_draw_visible= visible=
  127.   end
  128.   def visible=(bool)
  129.     # エネミーの場合
  130.     if @battler.is_a?(Game_Enemy)
  131.       @enemy_hpsp_window.visible = bool
  132.     end
  133.     # 元のメソッドに戻す
  134.     self.plan_enemy_hpsp_draw_visible=(bool)
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # ● 不透明度の設定
  138.   #--------------------------------------------------------------------------
  139.   if !method_defined?("plan_enemy_hpsp_draw_opacity=")
  140.     alias plan_enemy_hpsp_draw_opacity= opacity=
  141.   end
  142.   def opacity=(n)
  143.     # 元のメソッドに戻す
  144.     self.plan_enemy_hpsp_draw_opacity=(n)
  145.     # エネミーの場合
  146.     if @battler.is_a?(Game_Enemy)
  147.       @enemy_hpsp_window.contents_opacity = n
  148.     end
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # ● ダメージ
  152.   #--------------------------------------------------------------------------
  153.   def damage(value, critical)
  154.     super(value, critical)
  155.     bitmap = @_damage_sprite.bitmap
  156.     @_damage_sprite.dispose
  157.     @_damage_sprite = ::Sprite.new(Viewport.new(0, 0, 640, 480))
  158.     @_damage_sprite.bitmap = bitmap
  159.     @_damage_sprite.ox = 80
  160.     @_damage_sprite.oy = 20
  161.     @_damage_sprite.x = self.x
  162.     @_damage_sprite.y = self.y - self.oy / 2
  163.     @_damage_sprite.viewport.z = self.viewport.z + 1
  164.     @_damage_sprite.z = 3000
  165.     @_damage_duration = 40
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # ● ダメージ解放
  169.   #--------------------------------------------------------------------------
  170.   def dispose_damage
  171.     if @_damage_sprite != nil
  172.       @_damage_sprite.viewport.dispose
  173.     end
  174.     super
  175.   end
  176. end
  177. #==============================================================================
  178. # ■ Game_Temp
  179. #==============================================================================
  180.  
  181. class Game_Temp
  182.   #--------------------------------------------------------------------------
  183.   # ● 公開インスタンス変数
  184.   #--------------------------------------------------------------------------
  185.   attr_accessor :enemy_hpsp_refresh
  186.   #--------------------------------------------------------------------------
  187.   # ● オブジェクト初期化
  188.   #--------------------------------------------------------------------------
  189.   alias plan_enemy_hpsp_draw_initialize initialize
  190.   def initialize
  191.     # 元のメソッドに戻す
  192.     plan_enemy_hpsp_draw_initialize
  193.     @enemy_hpsp_refresh = false
  194.   end
  195. end
  196.  
  197. #==============================================================================
  198. # ■ Scene_Battle
  199. #==============================================================================
  200.  
  201. class Scene_Battle
  202.   #--------------------------------------------------------------------------
  203.   # ● プレバトルフェーズ開始 (エネミー名+アルファベット用)
  204.   #--------------------------------------------------------------------------
  205.   alias plan_enemy_hpsp_draw_start_phase1 start_phase1
  206.   def start_phase1
  207.     $game_temp.enemy_hpsp_refresh = true
  208.     # 元のメソッドに戻す
  209.     plan_enemy_hpsp_draw_start_phase1
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ● パーティコマンドフェーズ開始 (エネミー名+アルファベット用)
  213.   #--------------------------------------------------------------------------
  214.   alias plan_enemy_hpsp_draw_start_phase2 start_phase2
  215.   def start_phase2
  216.     $game_temp.enemy_hpsp_refresh = false
  217.     # 元のメソッドに戻す
  218.     plan_enemy_hpsp_draw_start_phase2
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  222.   #--------------------------------------------------------------------------
  223.   alias plan_enemy_hpsp_draw_update_phase4_step5 update_phase4_step5
  224.   def update_phase4_step5
  225.     # 元のメソッドに戻す
  226.     plan_enemy_hpsp_draw_update_phase4_step5
  227.     $game_temp.enemy_hpsp_refresh = true
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
  231.   #--------------------------------------------------------------------------
  232.   alias plan_enemy_hpsp_draw_update_phase4_step6 update_phase4_step6
  233.   def update_phase4_step6
  234.     # 元のメソッドに戻す
  235.     plan_enemy_hpsp_draw_update_phase4_step6
  236.     $game_temp.enemy_hpsp_refresh = false
  237.   end
  238. end
  239. #==============================================================================
  240. # ■ Window_Base
  241. #==============================================================================
  242. class Window_Base < Window
  243.   #--------------------------------------------------------------------------
  244.   # ● 名前の描画
  245.   #--------------------------------------------------------------------------
  246.   def draw_actor_name(actor, x, y, width = 120, align = 0)
  247.     self.contents.font.color = Color.new(0, 220, 0)
  248.     align = 1 if $scene.is_a?(Scene_Battle)
  249.     self.contents.draw_text(x, y, width, 32, actor.name, align)
  250.   end
  251. end

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
2
发表于 2015-9-26 00:05:44 | 只看该作者
35  36行  不能直接减去 width 或者 height
从Cache读取该敌人的Bitmap
然后计算
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-23 01:33

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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