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

Project1

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

[新手自制]根据血量绿黄红渐变的血条

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
65
在线时间
5 小时
注册时间
2006-8-21
帖子
417
跳转到指定楼层
1
发表于 2008-1-15 23:36:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
看了“七夕小雨”的教程http://rpg.blue/web/htm/news756.htm

有了一个血条绿黄红渐变的思路,自己写了一个脚本,希望高手指教一下。


原理就是做一个条件分歧

满血时红色最低,绿色最高

当超过半血的情况,红色随血的减少而增加,直到和绿色相等为止

当低于半血的情况,绿色随血的减少而减少,直到最低

附上色表一张:


使用方法:把Window_BattleStatus替换为以下脚本

  1. #==============================================================================
  2. # ■ 小翼(alwing)特制 HP MP 显示槽↓↓↓↓
  3. #==============================================================================
  4. # HP定义
  5. def HP(actor,x,y,w=94)
  6.   #底色定义
  7.   self.contents.fill_rect(x+26, y+14, w+4,12, Color.new(0,0,0,255))
  8.   self.contents.fill_rect(x+27, y+15, w+2,10, Color.new(255,255,255,255))
  9.   self.contents.fill_rect(x+28, y+16, w,8, Color.new(0,0,0,255))
  10.   #HP宽度定义
  11.   @HPw = w * actor.hp/actor.maxhp
  12.   #中
  13.   if actor.hp > actor.maxhp/2
  14.     @HPcg = 255
  15.     @HPcr = 150 + 105 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
  16.   else
  17.     @HPcr = 255
  18.     @HPcg = 150 + 105 * actor.hp/(actor.maxhp/2)
  19.   end
  20.   #中偏边
  21.   if actor.hp > actor.maxhp/2
  22.     @HPcg1 = 255
  23.     @HPcr1 = 100 + 155 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
  24.   else
  25.     @HPcr1 = 255
  26.     @HPcg1 = 100 + 155 * actor.hp/(actor.maxhp/2)
  27.   end
  28.   #边偏中
  29.   if actor.hp > actor.maxhp/2
  30.     @HPcg2 = 200
  31.     @HPcr2 = 50 + 150 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
  32.   else
  33.     @HPcr2 = 200
  34.     @HPcg2 = 50 + 150 * actor.hp/(actor.maxhp/2)
  35.   end
  36.   #边
  37.   if actor.hp > actor.maxhp/2
  38.     @HPcg3 = 150
  39.     @HPcr3 = 150 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
  40.   else
  41.     @HPcr3 = 150
  42.     @HPcg3 = 150 * actor.hp/(actor.maxhp/2)
  43.   end
  44.   
  45.   #HP条定义
  46.   self.contents.fill_rect(x+28, y+16, @HPw,1, Color.new(@HPcr3,@HPcg3,0,255))
  47.   self.contents.fill_rect(x+28, y+17, @HPw,1, Color.new(@HPcr2,@HPcg2,50,255))
  48.   self.contents.fill_rect(x+28, y+18, @HPw,1, Color.new(@HPcr1,@HPcg1,100,255))
  49.   #中
  50.   self.contents.fill_rect(x+28, y+19, @HPw,2, Color.new(@HPcr,@HPcg,150,255))
  51.   #中偏边
  52.   self.contents.fill_rect(x+28, y+21, @HPw,1, Color.new(@HPcr1,@HPcg1,100,255))
  53.   #边偏中
  54.   self.contents.fill_rect(x+28, y+22, @HPw,1, Color.new(@HPcr2,@HPcg2,50,255))
  55.   #边
  56.   self.contents.fill_rect(x+28, y+23, @HPw,1, Color.new(@HPcr3,@HPcg3,0,255))
  57. end

  58. # MP定义
  59. def MP(actor,x,y,w=94)
  60.   self.contents.fill_rect(x+26, y+46, w+4,12, Color.new(0,0,0,255))
  61.   self.contents.fill_rect(x+27, y+47, w+2,10, Color.new(255,255,255,255))
  62.   self.contents.fill_rect(x+28, y+48, w,8, Color.new(0,0,0,255))
  63.   @MPw = w * actor.sp/actor.maxsp
  64.   self.contents.fill_rect(x+28, y+48, @MPw,1, Color.new(0,0,150,255))
  65.   self.contents.fill_rect(x+28, y+49, @MPw,1, Color.new(50,50,200,255))
  66.   self.contents.fill_rect(x+28, y+50, @MPw,1, Color.new(100,100,255,255))
  67.   self.contents.fill_rect(x+28, y+51, @MPw,2, Color.new(150,150,255,255))#中
  68.   self.contents.fill_rect(x+28, y+53, @MPw,1, Color.new(100,100,255,255))
  69.   self.contents.fill_rect(x+28, y+54, @MPw,1, Color.new(50,50,200,255))
  70.   self.contents.fill_rect(x+28, y+55, @MPw,1, Color.new(0,0,150,255))
  71. end
  72. #==============================================================================
  73. # ■ 小翼(alwing)特制 HP MP 显示槽↑↑↑
  74. #==============================================================================

  75. #==============================================================================
  76. # ■ Window_BattleStatus
  77. #------------------------------------------------------------------------------
  78. #  显示战斗画面同伴状态的窗口。
  79. #==============================================================================

  80. class Window_BattleStatus < Window_Base
  81.   #--------------------------------------------------------------------------
  82.   # ● 初始化对像
  83.   #--------------------------------------------------------------------------
  84.   def initialize
  85.     super(0, 320, 640, 160)
  86.     self.contents = Bitmap.new(width - 32, height - 32)
  87.     @level_up_flags = [false, false, false, false]
  88.     refresh
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # ● 释放
  92.   #--------------------------------------------------------------------------
  93.   def dispose
  94.     super
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ● 设置升级标志
  98.   #     actor_index : 角色索引
  99.   #--------------------------------------------------------------------------
  100.   def level_up(actor_index)
  101.     @level_up_flags[actor_index] = true
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # ● 刷新
  105.   #--------------------------------------------------------------------------
  106.   def refresh
  107.     self.contents.clear
  108.     @item_max = $game_party.actors.size
  109.     for i in 0...$game_party.actors.size
  110.       actor = $game_party.actors[i]
  111.       actor_x = i * 160 + 4
  112.       draw_actor_name(actor, actor_x, 0)
  113.       HP(actor,actor_x,32)
  114.       MP(actor,actor_x,32)
  115.       draw_actor_hp(actor, actor_x, 32, 120)
  116.       draw_actor_sp(actor, actor_x, 64, 120)
  117.       if @level_up_flags[i]
  118.         self.contents.font.color = normal_color
  119.         self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
  120.       else
  121.         draw_actor_state(actor, actor_x, 96)
  122.       end
  123.     end
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # ● 刷新画面
  127.   #--------------------------------------------------------------------------
  128.   def update
  129.     super
  130.     # 主界面的不透明度下降
  131.     if $game_temp.battle_main_phase
  132.       self.contents_opacity -= 4 if self.contents_opacity > 191
  133.     else
  134.       self.contents_opacity += 4 if self.contents_opacity < 255
  135.     end
  136.   end
  137. end
复制代码

Lv1.梦旅人

梦石
0
星屑
65
在线时间
5 小时
注册时间
2006-8-21
帖子
417
2
 楼主| 发表于 2008-1-15 23:36:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
看了“七夕小雨”的教程http://rpg.blue/web/htm/news756.htm

有了一个血条绿黄红渐变的思路,自己写了一个脚本,希望高手指教一下。


原理就是做一个条件分歧

满血时红色最低,绿色最高

当超过半血的情况,红色随血的减少而增加,直到和绿色相等为止

当低于半血的情况,绿色随血的减少而减少,直到最低

附上色表一张:


使用方法:把Window_BattleStatus替换为以下脚本

  1. #==============================================================================
  2. # ■ 小翼(alwing)特制 HP MP 显示槽↓↓↓↓
  3. #==============================================================================
  4. # HP定义
  5. def HP(actor,x,y,w=94)
  6.   #底色定义
  7.   self.contents.fill_rect(x+26, y+14, w+4,12, Color.new(0,0,0,255))
  8.   self.contents.fill_rect(x+27, y+15, w+2,10, Color.new(255,255,255,255))
  9.   self.contents.fill_rect(x+28, y+16, w,8, Color.new(0,0,0,255))
  10.   #HP宽度定义
  11.   @HPw = w * actor.hp/actor.maxhp
  12.   #中
  13.   if actor.hp > actor.maxhp/2
  14.     @HPcg = 255
  15.     @HPcr = 150 + 105 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
  16.   else
  17.     @HPcr = 255
  18.     @HPcg = 150 + 105 * actor.hp/(actor.maxhp/2)
  19.   end
  20.   #中偏边
  21.   if actor.hp > actor.maxhp/2
  22.     @HPcg1 = 255
  23.     @HPcr1 = 100 + 155 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
  24.   else
  25.     @HPcr1 = 255
  26.     @HPcg1 = 100 + 155 * actor.hp/(actor.maxhp/2)
  27.   end
  28.   #边偏中
  29.   if actor.hp > actor.maxhp/2
  30.     @HPcg2 = 200
  31.     @HPcr2 = 50 + 150 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
  32.   else
  33.     @HPcr2 = 200
  34.     @HPcg2 = 50 + 150 * actor.hp/(actor.maxhp/2)
  35.   end
  36.   #边
  37.   if actor.hp > actor.maxhp/2
  38.     @HPcg3 = 150
  39.     @HPcr3 = 150 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
  40.   else
  41.     @HPcr3 = 150
  42.     @HPcg3 = 150 * actor.hp/(actor.maxhp/2)
  43.   end
  44.   
  45.   #HP条定义
  46.   self.contents.fill_rect(x+28, y+16, @HPw,1, Color.new(@HPcr3,@HPcg3,0,255))
  47.   self.contents.fill_rect(x+28, y+17, @HPw,1, Color.new(@HPcr2,@HPcg2,50,255))
  48.   self.contents.fill_rect(x+28, y+18, @HPw,1, Color.new(@HPcr1,@HPcg1,100,255))
  49.   #中
  50.   self.contents.fill_rect(x+28, y+19, @HPw,2, Color.new(@HPcr,@HPcg,150,255))
  51.   #中偏边
  52.   self.contents.fill_rect(x+28, y+21, @HPw,1, Color.new(@HPcr1,@HPcg1,100,255))
  53.   #边偏中
  54.   self.contents.fill_rect(x+28, y+22, @HPw,1, Color.new(@HPcr2,@HPcg2,50,255))
  55.   #边
  56.   self.contents.fill_rect(x+28, y+23, @HPw,1, Color.new(@HPcr3,@HPcg3,0,255))
  57. end

  58. # MP定义
  59. def MP(actor,x,y,w=94)
  60.   self.contents.fill_rect(x+26, y+46, w+4,12, Color.new(0,0,0,255))
  61.   self.contents.fill_rect(x+27, y+47, w+2,10, Color.new(255,255,255,255))
  62.   self.contents.fill_rect(x+28, y+48, w,8, Color.new(0,0,0,255))
  63.   @MPw = w * actor.sp/actor.maxsp
  64.   self.contents.fill_rect(x+28, y+48, @MPw,1, Color.new(0,0,150,255))
  65.   self.contents.fill_rect(x+28, y+49, @MPw,1, Color.new(50,50,200,255))
  66.   self.contents.fill_rect(x+28, y+50, @MPw,1, Color.new(100,100,255,255))
  67.   self.contents.fill_rect(x+28, y+51, @MPw,2, Color.new(150,150,255,255))#中
  68.   self.contents.fill_rect(x+28, y+53, @MPw,1, Color.new(100,100,255,255))
  69.   self.contents.fill_rect(x+28, y+54, @MPw,1, Color.new(50,50,200,255))
  70.   self.contents.fill_rect(x+28, y+55, @MPw,1, Color.new(0,0,150,255))
  71. end
  72. #==============================================================================
  73. # ■ 小翼(alwing)特制 HP MP 显示槽↑↑↑
  74. #==============================================================================

  75. #==============================================================================
  76. # ■ Window_BattleStatus
  77. #------------------------------------------------------------------------------
  78. #  显示战斗画面同伴状态的窗口。
  79. #==============================================================================

  80. class Window_BattleStatus < Window_Base
  81.   #--------------------------------------------------------------------------
  82.   # ● 初始化对像
  83.   #--------------------------------------------------------------------------
  84.   def initialize
  85.     super(0, 320, 640, 160)
  86.     self.contents = Bitmap.new(width - 32, height - 32)
  87.     @level_up_flags = [false, false, false, false]
  88.     refresh
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # ● 释放
  92.   #--------------------------------------------------------------------------
  93.   def dispose
  94.     super
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ● 设置升级标志
  98.   #     actor_index : 角色索引
  99.   #--------------------------------------------------------------------------
  100.   def level_up(actor_index)
  101.     @level_up_flags[actor_index] = true
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # ● 刷新
  105.   #--------------------------------------------------------------------------
  106.   def refresh
  107.     self.contents.clear
  108.     @item_max = $game_party.actors.size
  109.     for i in 0...$game_party.actors.size
  110.       actor = $game_party.actors[i]
  111.       actor_x = i * 160 + 4
  112.       draw_actor_name(actor, actor_x, 0)
  113.       HP(actor,actor_x,32)
  114.       MP(actor,actor_x,32)
  115.       draw_actor_hp(actor, actor_x, 32, 120)
  116.       draw_actor_sp(actor, actor_x, 64, 120)
  117.       if @level_up_flags[i]
  118.         self.contents.font.color = normal_color
  119.         self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
  120.       else
  121.         draw_actor_state(actor, actor_x, 96)
  122.       end
  123.     end
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # ● 刷新画面
  127.   #--------------------------------------------------------------------------
  128.   def update
  129.     super
  130.     # 主界面的不透明度下降
  131.     if $game_temp.battle_main_phase
  132.       self.contents_opacity -= 4 if self.contents_opacity > 191
  133.     else
  134.       self.contents_opacity += 4 if self.contents_opacity < 255
  135.     end
  136.   end
  137. end
复制代码

Lv1.梦旅人

梦石
0
星屑
50
在线时间
9 小时
注册时间
2007-8-22
帖子
95
3
发表于 2008-1-16 02:55:55 | 只看该作者
我以前似乎弄过一个2条血的血条
不要麻仁.
回复 支持 反对

使用道具 举报

Lv3.寻梦者 (暗夜天使)

精灵族の天使

梦石
0
星屑
1702
在线时间
3038 小时
注册时间
2007-3-16
帖子
33731

开拓者贵宾

4
发表于 2008-1-16 03:28:46 | 只看该作者
以前清爽版血条似乎就是渐变的呢。
你可以修改一下sp从蓝到深绿的渐变。
回复 支持 反对

使用道具 举报

Lv5.捕梦者

御灵的宠物

梦石
12
星屑
8481
在线时间
94 小时
注册时间
2006-12-11
帖子
3156

第2届TG大赛亚军

5
发表于 2008-1-16 03:33:22 | 只看该作者
这个血条满好看的啊
顺便膜拜LZ的头像
我的Lofter:http://nightoye.lofter.com/

回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

心无天使

梦石
0
星屑
49
在线时间
0 小时
注册时间
2007-12-15
帖子
1016
6
发表于 2008-1-16 03:52:52 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
5 小时
注册时间
2006-8-21
帖子
417
7
 楼主| 发表于 2008-1-16 09:24:58 | 只看该作者
是啊,我也是在动画中拉条子看颜色的,基本原理就是
绿 + 红 = 黄 (R,G,B,255) R=G
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

风吹过的晴天

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-1-17
帖子
607
8
发表于 2008-1-17 07:21:15 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-7-8 06:13

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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