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

Project1

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

[已经解决] 血条问题!跪求大神帮助

[复制链接]

Lv1.梦旅人

梦石
0
星屑
854
在线时间
18 小时
注册时间
2014-1-5
帖子
3
跳转到指定楼层
1
发表于 2014-1-9 22:17:57 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 zcz260806542 于 2014-1-10 12:30 编辑


如图,我想要做的是怪物血条跟着怪物跑,结果血条只做平行移动,什么情况::>_<:: 求大神帮助啊
RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]http://rpg.blue/web/[/url],使用和转载请保留此信息
  3. #==============================================================================
  4. # ■ エネミーHP&SP(ver 0.98)
  5.  
  6. # □ カスタマイズポイント
  7. #==============================================================================
  8. begin
  9.  
  10. module PLAN_HPSP_DRAW
  11. FONT_NAME         = ["黑体", "楷体", "宋体"]    # フォント
  12. FONT_SIZE         =  12                               # フォントサイズ
  13. FONT_BOLD         = false                              # 太字
  14. FONT_ITALIC       = false                              # 斜体
  15.  
  16. DRAW_NAME         = false                             # 名前の描画
  17. DRAW_HP           = true                              # HP の描画
  18. DRAW_SP           = true                              # SP の描画
  19.  
  20. DRAW_WIDTH        =  80                               # 描画幅
  21. DRAW_HEIGHT       = 3 * 32                            # 描画高さ
  22. DRAW_SPACE        =   0                               # 行間
  23. DRAW_Y            =  36                               # Y 座標修正値
  24. end
  25.  
  26.  
  27. #==============================================================================
  28. # ■ Sprite_Battler
  29. #==============================================================================
  30.  
  31. class Sprite_Battler < RPG::Sprite
  32. #--------------------------------------------------------------------------
  33. # ● オブジェクト初期化
  34. #--------------------------------------------------------------------------
  35. alias plan_enemy_hpsp_draw_initialize initialize
  36. def initialize(viewport, battler = nil)
  37.    # 元のメソッドに戻す
  38.    plan_enemy_hpsp_draw_initialize(viewport, battler)
  39.    # エネミーの場合
  40.    if @battler.is_a?(Game_Enemy)
  41.      width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  42.      height = PLAN_HPSP_DRAW::DRAW_HEIGHT + 32
  43.      x = @battler.screen_x - width / 2
  44.      y = @battler.screen_y - height + 32 + PLAN_HPSP_DRAW::DRAW_Y
  45.      @enemy_hpsp_window = Window_Base.new(x, y, width, height)
  46.      @enemy_hpsp_window.contents = Bitmap.new(width - 32, height - 32)
  47.      @enemy_hpsp_window.contents.font.name = PLAN_HPSP_DRAW::FONT_NAME
  48.      @enemy_hpsp_window.contents.font.size = PLAN_HPSP_DRAW::FONT_SIZE
  49.      @enemy_hpsp_window.contents.font.bold = PLAN_HPSP_DRAW::FONT_BOLD
  50.      @enemy_hpsp_window.contents.font.italic = PLAN_HPSP_DRAW::FONT_ITALIC
  51.      y = 0
  52.      @old_enemy_hpsp = []
  53.      one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
  54.      if PLAN_HPSP_DRAW::DRAW_NAME
  55.        @enemy_hpsp_window.draw_actor_name(@battler, 0, y, width - 32)
  56.        y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  57.        @old_enemy_hpsp.push(@battler.name)
  58.      end
  59.      if PLAN_HPSP_DRAW::DRAW_HP
  60.        @enemy_hpsp_window.draw_actor_hp2222(@battler, 0, y, width - 32)
  61.        y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  62.        @old_enemy_hpsp.push(@battler.hp)
  63.      end
  64.      if PLAN_HPSP_DRAW::DRAW_SP
  65.        @enemy_hpsp_window.draw_actor_sp2222(@battler, 0, y, width - 32)
  66.        @old_enemy_hpsp.push(@battler.sp)
  67.      end
  68.      @enemy_hpsp_window.opacity = 0
  69.      @enemy_hpsp_window.contents_opacity = 0
  70.      @enemy_hpsp_window.z = -2
  71.    end
  72. end
  73. #--------------------------------------------------------------------------
  74. # ● 解放
  75. #--------------------------------------------------------------------------
  76. alias plan_enemy_hpsp_draw_dispose dispose
  77. def dispose
  78.    # エネミーの場合
  79.    if @battler.is_a?(Game_Enemy)
  80.      @enemy_hpsp_window.dispose
  81.    end
  82.    # 元のメソッドに戻す
  83.    plan_enemy_hpsp_draw_dispose
  84. end
  85. #--------------------------------------------------------------------------
  86. # ● フレーム更新
  87. #--------------------------------------------------------------------------
  88. alias plan_enemy_hpsp_draw_update update
  89. def update
  90.    # 元のメソッドに戻す
  91.    plan_enemy_hpsp_draw_update
  92.    # エネミーの場合
  93.    if @battler.is_a?(Game_Enemy)
  94.      @enemy_hpsp_window.visible = @battler_visible
  95.    # スプライトの座標を設定
  96.      width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  97.      @enemy_hpsp_window.x = self.x - width / 2
  98.      @now_enemy_hpsp = []
  99.      if PLAN_HPSP_DRAW::DRAW_NAME
  100.        @now_enemy_hpsp.push(@battler.name)
  101.      end
  102.      if PLAN_HPSP_DRAW::DRAW_HP
  103.        @now_enemy_hpsp.push(@battler.hp)
  104.      end
  105.      if PLAN_HPSP_DRAW::DRAW_SP
  106.        @now_enemy_hpsp.push(@battler.sp)
  107.      end
  108.      if @old_enemy_hpsp != @now_enemy_hpsp and $game_temp.enemy_hpsp_refresh
  109.        @old_enemy_hpsp = @now_enemy_hpsp
  110.        @enemy_hpsp_window.contents.clear
  111.        y = 0
  112.        width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  113.        one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
  114.        if PLAN_HPSP_DRAW::DRAW_NAME
  115.          @enemy_hpsp_window.draw_actor_name(@battler, 0, y, width - 32)
  116.          y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  117.        end
  118.        if PLAN_HPSP_DRAW::DRAW_HP
  119.          @enemy_hpsp_window.draw_actor_hp2222(@battler, 0, y, width - 32)
  120.          y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  121.        end
  122.        if PLAN_HPSP_DRAW::DRAW_SP
  123.          @enemy_hpsp_window.draw_actor_sp2222(@battler, 0, y, width - 32)
  124.        end
  125.        Graphics.frame_reset
  126.      end
  127.    end
  128. end
  129. #--------------------------------------------------------------------------
  130. # ● visible の設定
  131. #--------------------------------------------------------------------------
  132. if !method_defined?("plan_enemy_hpsp_draw_visible=")
  133.    alias plan_enemy_hpsp_draw_visible= visible=
  134. end
  135. def visible=(bool)
  136.    # エネミーの場合
  137.    if @battler.is_a?(Game_Enemy)
  138.      @enemy_hpsp_window.visible = bool
  139.    end
  140.    # 元のメソッドに戻す
  141.    self.plan_enemy_hpsp_draw_visible=(bool)
  142. end
  143. #--------------------------------------------------------------------------
  144. # ● 不透明度の設定
  145. #--------------------------------------------------------------------------
  146. if !method_defined?("plan_enemy_hpsp_draw_opacity=")
  147.    alias plan_enemy_hpsp_draw_opacity= opacity=
  148. end
  149. def opacity=(n)
  150.    # 元のメソッドに戻す
  151.    self.plan_enemy_hpsp_draw_opacity=(n)
  152.    # エネミーの場合
  153.    if @battler.is_a?(Game_Enemy)
  154.      @enemy_hpsp_window.contents_opacity = n
  155.    end
  156. end
  157. #--------------------------------------------------------------------------
  158. # ● ダメージ
  159. #--------------------------------------------------------------------------
  160. def damage(value, critical)
  161.    super(value, critical)
  162.    bitmap = @_damage_sprite.bitmap
  163.    @_damage_sprite.dispose
  164.    @_damage_sprite = ::Sprite.new(Viewport.new(0, 0, 640, 480))
  165.    @_damage_sprite.bitmap = bitmap
  166.    @_damage_sprite.ox = 80
  167.    @_damage_sprite.oy = 20
  168.    @_damage_sprite.x = self.x
  169.    @_damage_sprite.y = self.y - self.oy / 2
  170.    @_damage_sprite.viewport.z = self.viewport.z + 1
  171.    @_damage_sprite.z = 3000
  172.    @_damage_duration = 40
  173. end
  174. #--------------------------------------------------------------------------
  175. # ● ダメージ解放
  176. #--------------------------------------------------------------------------
  177. def dispose_damage
  178.    if @_damage_sprite != nil
  179.      @_damage_sprite.viewport.dispose
  180.    end
  181.    super
  182. end
  183. end
  184.  
  185.  
  186.  
  187.  
  188.  
  189. #==============================================================================
  190. # ■ Game_Temp
  191. #==============================================================================
  192.  
  193. class Game_Temp
  194. #--------------------------------------------------------------------------
  195. # ● 公開インスタンス変数
  196. #--------------------------------------------------------------------------
  197. attr_accessor :enemy_hpsp_refresh
  198. #--------------------------------------------------------------------------
  199. # ● オブジェクト初期化
  200. #--------------------------------------------------------------------------
  201. alias plan_enemy_hpsp_draw_initialize initialize
  202. def initialize
  203.    # 元のメソッドに戻す
  204.    plan_enemy_hpsp_draw_initialize
  205.    @enemy_hpsp_refresh = false
  206. end
  207. end
  208.  
  209. #==============================================================================
  210. # ■ Scene_Battle
  211. #==============================================================================
  212.  
  213. class Scene_Battle
  214. #--------------------------------------------------------------------------
  215. # ● プレバトルフェーズ開始 (エネミー名+アルファベット用)
  216. #--------------------------------------------------------------------------
  217. alias plan_enemy_hpsp_draw_start_phase1 start_phase1
  218. def start_phase1
  219.    $game_temp.enemy_hpsp_refresh = true
  220.    # 元のメソッドに戻す
  221.    plan_enemy_hpsp_draw_start_phase1
  222. end
  223. #--------------------------------------------------------------------------
  224. # ● パーティコマンドフェーズ開始 (エネミー名+アルファベット用)
  225. #--------------------------------------------------------------------------
  226. alias plan_enemy_hpsp_draw_start_phase2 start_phase2
  227. def start_phase2
  228.    $game_temp.enemy_hpsp_refresh = false
  229.    # 元のメソッドに戻す
  230.    plan_enemy_hpsp_draw_start_phase2
  231. end
  232. #--------------------------------------------------------------------------
  233. # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  234. #--------------------------------------------------------------------------
  235. alias plan_enemy_hpsp_draw_update_phase4_step5 update_phase4_step5
  236. def update_phase4_step5
  237.    # 元のメソッドに戻す
  238.    plan_enemy_hpsp_draw_update_phase4_step5
  239.    $game_temp.enemy_hpsp_refresh = true#
  240. end
  241. #--------------------------------------------------------------------------
  242. # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
  243. #--------------------------------------------------------------------------
  244. alias plan_enemy_hpsp_draw_update_phase4_step6 update_phase4_step6
  245. def update_phase4_step6
  246.    # 元のメソッドに戻す
  247.    plan_enemy_hpsp_draw_update_phase4_step6
  248.    $game_temp.enemy_hpsp_refresh = false
  249. end
  250. end
  251.  
  252.  
  253. #==============================================================================
  254. # ■ Window_Base
  255. #==============================================================================
  256.  
  257. class Window_Base < Window
  258. #--------------------------------------------------------------------------
  259. # ● 名前の描画
  260. #--------------------------------------------------------------------------
  261. def draw_actor_name(actor, x, y, width = 120, align = 0)
  262.    self.contents.font.color = normal_color
  263.    align = 1 if $scene.is_a?(Scene_Battle)
  264.    self.contents.draw_text(x, y, width, 32, actor.name, align)
  265. end
  266. #--------------------------------------------------------------------------
  267. # ● ステートの描画
  268. #--------------------------------------------------------------------------
  269. def draw_actor_state(actor, x, y, width = 120)
  270.    # 元のメソッドに戻す
  271.    text = make_battler_state_text(actor, width, true)
  272.    self.contents.draw_text(x, y, width, 32, text, 1)
  273. end
  274. end
  275.  
  276.  
  277. #==============================================================================
  278. # 本脚本来自[url]http://rpg.blue/web/[/url],使用和转载请保留此信息
  279. #==============================================================================
  280.  
  281. class Window_Base < Window
  282.   def draw_actor_hp2222(actor, x, y, width = 100, height=8)
  283.     y+=3
  284.     olx = x
  285.     oly = y
  286.     w = width * actor.hp / [actor.maxhp,1].max
  287.     hp_color_1 = Color.new(180, 18, 0, 255)
  288.     hp_color_2 = Color.new(255, 140, 140, 255)
  289.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  290.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  291.     x -= 1
  292.     y += (height/4).floor
  293.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  294.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  295.     x -= 1
  296.     y += (height/4).ceil
  297.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  298.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  299.     x -= 1
  300.     y += (height/4).ceil
  301.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  302.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  303.     x = olx
  304.     y = oly-14   
  305.     # 描绘字符串 "HP"
  306.     self.contents.font.color = system_color
  307.     self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
  308.     # 计算描绘 MaxHP 所需的空间
  309.     if width - 32 >= 108
  310.       hp_x = x + width - 108
  311.       flag = true
  312.     elsif width - 32 >= 48
  313.       hp_x = x + width - 48
  314.       flag = false
  315.     end
  316.     # 描绘 HP
  317.     self.contents.font.color = actor.hp == 0 ? knockout_color :
  318.       actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  319.     self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
  320.     # 描绘 MaxHP
  321.     if flag
  322.       self.contents.font.color = normal_color
  323.       self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
  324.       self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
  325.     end   
  326.   end
  327.   def draw_actor_sp2222(actor, x, y, width = 100, height = 8)
  328.     y+=3
  329.     olx = x
  330.     oly = y
  331.     w = width * actor.sp / [actor.maxsp,1].max
  332.     hp_color_1 = Color.new( 78, 10, 175, 255)
  333.     hp_color_2 = Color.new( 40, 176, 255, 255)
  334.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  335.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  336.     x -= 1
  337.     y += (height/4).floor
  338.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  339.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  340.     x -= 1
  341.     y += (height/4).ceil
  342.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  343.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  344.     x -= 1
  345.     y += (height/4).ceil
  346.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  347.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  348.     x = olx
  349.     y = oly-14
  350.     # 描绘字符串 "SP"
  351.     self.contents.font.color = system_color
  352.     self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
  353.     # 计算描绘 MaxSP 所需的空间
  354.     if width - 32 >= 108
  355.       sp_x = x + width - 108
  356.       flag = true
  357.     elsif width - 32 >= 48
  358.       sp_x = x + width - 48
  359.       flag = false
  360.     end
  361.     # 描绘 SP
  362.     self.contents.font.color = actor.sp == 0 ? knockout_color :
  363.       actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  364.     self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
  365.     # 描绘 MaxSP
  366.     if flag
  367.       self.contents.font.color = normal_color
  368.       self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
  369.       self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
  370.     end   
  371.   end
  372.   #--------------------------------------------------------------------------
  373.   # ● ライン描画 by 桜雅 在土
  374.   #--------------------------------------------------------------------------
  375.   def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color)
  376.     # 描写距離の計算。大きめに直角時の長さ。
  377.     distance = (start_x - end_x).abs + (start_y - end_y).abs
  378.     # 描写開始
  379.     if end_color == start_color
  380.       for i in 1..distance
  381.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  382.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  383.         if width == 1
  384.           self.contents.set_pixel(x, y, start_color)
  385.         else
  386.           self.contents.fill_rect(x, y, width, width, start_color)
  387.         end
  388.       end
  389.     else
  390.       for i in 1..distance
  391.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  392.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  393.         r = start_color.red * (distance-i)/distance + end_color.red * i/distance
  394.         g = start_color.green * (distance-i)/distance + end_color.green * i/distance
  395.         b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance
  396.         a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance
  397.         if width == 1
  398.           self.contents.set_pixel(x, y, Color.new(r, g, b, a))
  399.         else
  400.           self.contents.fill_rect(x, y, width, width, Color.new(r, g, b, a))
  401.         end
  402.       end
  403.     end
  404.   end
  405. end
  406. #==============================================================================
  407. # 本脚本来自[url]http://rpg.blue/web/[/url],使用和转载请保留此信息
  408. #==============================================================================
  409. end

Lv4.逐梦者

「Pemercyia」


Urhurrenna

梦石
0
星屑
9397
在线时间
2748 小时
注册时间
2008-9-5
帖子
3543

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

2
发表于 2014-1-10 10:29:54 | 只看该作者
看了一下~
试试这样:
上面的脚本97行
  1. @enemy_hpsp_window.x = self.x - width / 2
复制代码
这里是刷新x坐标的~
试试看在下面写多两行
  1. height = PLAN_HPSP_DRAW::DRAW_HEIGHT + 32
  2. @enemy_hpsp_window.y = self.y - height + 32 + PLAN_HPSP_DRAW::DRAW_Y
复制代码
具体效果没测试~
以上~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
854
在线时间
18 小时
注册时间
2014-1-5
帖子
3
3
 楼主| 发表于 2014-1-10 12:30:04 | 只看该作者
cinderelmini 发表于 2014-1-10 10:29
看了一下~
试试这样:
上面的脚本97行这里是刷新x坐标的~

   非常感谢::>_<:: 终于好了
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-30 13:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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