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

Project1

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

[已经解决] 求助,如何通过替换图片来实现图片制血条的逐渐变色功能

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
24 小时
注册时间
2012-9-16
帖子
12
跳转到指定楼层
1
发表于 2014-7-9 20:44:52 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 桐人 于 2014-7-11 19:22 编辑

就是想制作一个随着血量的减少血条的颜色改变的一个功能。由于采用的是脚本制的图片血条,所以在网上查了半天也没有相关信息,我试了一下写条件分歧,不过没有成功。三种颜色的图片都放进去了,希望大家能够帮帮我,告诉我怎么才能通过脚本实现图片的替换。


哦对了,还请问一下,这个血条能实现渐降效果吗?难吗?
Project4.rar (211.53 KB, 下载次数: 25)

Lv1.梦旅人

梦石
0
星屑
68
在线时间
585 小时
注册时间
2013-5-25
帖子
1524
2
发表于 2014-7-10 10:49:38 | 只看该作者
本帖最后由 RyanBern 于 2014-7-10 12:07 编辑

将原来绿色的血条色相逆时针转过90°就能变成红色
用下面这个计算式达到目的
90 *Math.sqrt( actor.hp.to_f / actor.maxhp) - 90

因为如果是用一次函数的话血条变黄太快,换了根式

增加脚本见09行
  1. def HP(actor,x,y,w=74,width=144)
  2.   # HP条
  3.   #HP最大值
  4.   @bitmap1 =Bitmap.new("Graphics/Pictures/HP")
  5.   [email protected] *actor.hp/actor.maxhp
  6.   @src_rect1 = Rect.new( 0, 0, w1, @bitmap1.height)   
  7.   self.contents.blt(x+119,y+11,@bitmap1,@src_rect1)
  8.   self.contents.hue_change 90 *Math.sqrt( actor.hp.to_f / actor.maxhp) - 90
  9.   @bitmap3 =Bitmap.new("Graphics/Pictures/MHP")
  10.   [email protected]   
  11.   @src_rect3 = Rect.new( 0, 0, w3, @bitmap3.height)
  12.   self.contents.blt(x+38,y-22,@bitmap3,@src_rect3)
  13.   #HP  
  14.   hp_x = x
  15.   flag = false
  16.   self.contents.font.color = actor.hp == 0 ? knockout_color :
  17.        actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  18.   # 描绘 MaxHP
  19.   if flag
  20.     self.contents.font.color =normal_color
  21.     self.contents.draw_text(hp_x + 20, y+40, 12, 20, "/", 1)
  22.     self.contents.draw_number(hp_x + 35, y, actor.maxhp.to_s)     
  23.   end
  24. end

  25. #SP条
  26. def SP(actor,x,y,w=74,width=144)
  27.   #SP最大值
  28.   @bitmap4 =Bitmap.new("Graphics/Pictures/MSP")  
  29.   [email protected]
  30.   @src_rect4 = Rect.new( 0, 0, w4, @bitmap4.height)
  31.   self.contents.blt(x+68,y,@bitmap4,@src_rect4)
  32.   #sp
  33.   @bitmap2 =Bitmap.new("Graphics/Pictures/SP")
  34.   [email protected] *actor.sp/actor.maxsp
  35.   @src_rect2 = Rect.new( 0, 0, w2, @bitmap2.height)
  36.   self.contents.blt(x+68,y,@bitmap2,@src_rect2)
  37.   sp_x = x
  38.   flag = false
  39.   # 描绘 SP
  40.   self.contents.font.color = actor.sp == 0 ? knockout_color :
  41.        actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  42.   # 描绘 MaxSP
  43.   if flag
  44.     self.contents.font.color = normal_color
  45.     self.contents.draw_text(sp_x + 20, y+41, 13, 20, "/", 1)
  46.     #把括号后的2去掉,中间的两个数字也去掉,
  47.     self.contents.draw_number(sp_x + 35, y,  actor.maxsp.to_s)
  48.     #把draw_text改为draw_number就行了!!
  49.   end
  50. end
复制代码

点评

帮您编辑了脚本缩进~  发表于 2014-7-10 12:08

评分

参与人数 1星屑 +100 收起 理由
RyanBern + 100 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
24 小时
注册时间
2012-9-16
帖子
12
3
 楼主| 发表于 2014-7-10 16:12:38 | 只看该作者
谢谢您了,解决了!

点评

这不是在下一直想写的么!, 于是看了此贴决定现在自己写个出来  发表于 2014-7-10 17:49

评分

参与人数 1星屑 +100 收起 理由
克莉丝 + 100 你的验证邮箱任务坑了?

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 04:13

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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