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

Project1

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

[已经解决] 血槽计算公式求教

[复制链接]

Lv2.观梦者

梦石
0
星屑
596
在线时间
797 小时
注册时间
2014-7-1
帖子
578

开拓者

跳转到指定楼层
1
发表于 2016-10-8 17:55:15 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
如图 血槽采用四张图片来设定

每一张图片只计算角色25%的血量

这个公式应该怎么去计算呢!

就像一些网络游戏一样   血条有好几层一样


RUBY 代码复制
  1. def draw_actor_hp1_bar(actor, x, y,height=60)
  2.  
  3.     bitmap3=Bitmap.new("Graphics/Pictures/xue4")
  4.     w4 = 1.0 * actor.hp / actor.maxhp * height
  5.     src_rect3 = Rect.new(0, 0, 60,w4)
  6.     self.contents.blt(x+300, y, bitmap3, src_rect3)
  7.  
  8.     bitmap2=Bitmap.new("Graphics/Pictures/xue3") # 60  60
  9.     w3 = 1.0 * actor.hp / actor.maxhp * height
  10.     src_rect2 = Rect.new(0, 0, 60,w3)
  11.     self.contents.blt(x+200, y, bitmap2, src_rect2)
  12.  
  13.     bitmap1=Bitmap.new("Graphics/Pictures/xue2")
  14.     w2 = 1.0 * actor.hp / actor.maxhp * height
  15.     src_rect1 = Rect.new(0, 0, 60,w2)
  16.     self.contents.blt(x+100, y, bitmap1, src_rect1)
  17.  
  18.     bitmap=Bitmap.new("Graphics/Pictures/xue1") # 60  60
  19.     w1 = 1.0 * actor.hp / actor.maxhp * height
  20.     src_rect = Rect.new(0, 0, 60,w1)
  21.     self.contents.blt(x, y, bitmap, src_rect)
  22.  
  23.   end

血槽图片.png (39.01 KB, 下载次数: 5)

血槽图片.png
学习使我疲劳,打工使我疲惫,恋爱使我伤身,吸烟伤我肺腑,饮酒损我形象,旅游使我破费,月底不见铜板,只有在论坛里面看看各种大佬才能使我进去

Lv5.捕梦者

梦石
0
星屑
33071
在线时间
5103 小时
注册时间
2012-11-19
帖子
4878

开拓者

2
发表于 2016-10-9 18:56:33 | 只看该作者
随手瞎写的

  1. def draw_actor_hp1_bar(actor, x, y,height=60)
  2.     ar = []
  3.     data = actor.hp
  4.     names = ["xue4","xue3","xue2","xue1"]
  5.     n = actor.maxhp / 4
  6.     4.times do
  7.       nhp = [[n, data].min, 0].max
  8.       data -= nhp
  9.       ar << nhp
  10.     end
  11.     for i in 0..3
  12.       next if i != 3 and ar[i+1] == n
  13.       bitmap = Bitmap.new("Graphics/Pictures/#{names[i]}")
  14.       w = 1.0 * ar[i] / n * height
  15.       src_rect = Rect.new(0, 0, 60, w)
  16.       self.contents.blt(x, y, bitmap, src_rect)
  17.     end
  18.   end
复制代码

点评

谢谢芯大!!!!  发表于 2016-10-10 08:04

评分

参与人数 2星屑 +220 收起 理由
RyanBern + 200 认可答案
jiushiainilip19 + 20 认可答案

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 07:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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