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

Project1

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

[已经解决] HP MP显示出现小数点

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3186
在线时间
1863 小时
注册时间
2010-6-19
帖子
1205
跳转到指定楼层
1
发表于 2015-2-2 19:32:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
貌似用了下面的脚本,HP和MP显示出现了小数点。如何去掉小数点呢。
  1. #==============================================================================
  2. # ■ JD_DL
  3. #------------------------------------------------------------------------------
  4. #  显示加点状态窗口。
  5. #==============================================================================
  6. class JD_DL < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     actor : 角色
  10.   #--------------------------------------------------------------------------
  11.   def initialize(actor)
  12.     super(320, 0, 330, 360)
  13.     self.contents = Bitmap.new(width - 32, height - 32)
  14.     self.contents.font.size = 16
  15.     @actor = actor
  16.     # ** 文字高
  17.     # ** 可以放在refresh里 实时控制
  18.     @sh = 32
  19.     self.opacity = 0
  20.     refresh
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 刷新
  24.   #--------------------------------------------------------------------------
  25.   def refresh
  26.     self.contents.clear
  27.     self.contents.font.name = (["宋体","黑体"])
  28.   
  29.     # 属性
  30.     draw_v(-73, 144, 0)                     # 气血
  31.     draw_v(-73, 144+28, 1)                  # 法力
  32.    
  33.      
  34.     # 潜力描绘
  35.     self.contents.font.color = Color.new(255, 255, 255, 255)
  36.     str = ""#潜力"
  37.     self.contents.draw_text(160, 28*4-1, sw(str), @sh, str)
  38.     cx = sw(str)

  39.     # 潜能点
  40.     self.contents.draw_text(102, 28*4-3, self.width - 40, @sh, $point.to_s, 1)

  41.   # ** 返回字符串的宽度
  42.   def sw(s)
  43.     return self.contents.text_size(s).width
  44.   end
  45.   
  46.   # ** HP AND SP 描绘
  47.   def draw_v(x, y, type)
  48.     case type
  49.     when 0
  50.       word = ""#$data_system.words.hp    # HP
  51.       dl = @actor.hp
  52.       max = @actor.maxhp
  53.       temp = $temp_hp
  54.     when 1
  55.       word = ""#$data_system.words.sp    # MP
  56.       dl = @actor.sp
  57.       max = @actor.maxsp
  58.       temp = $temp_sp
  59.     else
  60.       return
  61.     end
  62.     self.contents.font.color = Color.new(255, 255, 255, 255)
  63.     # ** 用语
  64.     str = word
  65.     self.contents.draw_text(x, y, sw(str), @sh, str)
  66.     self.contents.font.color = Color.new(255, 255, 255, 255)
  67.     # ** 基本值
  68.     cx = sw(str)
  69.     #str = dl.to_s# + " "#"/"
  70.     self.contents.draw_text(x + cx + 23, y, self.width - 40, 32, "/",1)
  71.     self.contents.draw_text(x + cx - 127, y, self.width - 40, @sh, dl.to_s, 2)
  72.     cx += sw(str)
  73.     # ** 调整颜色
  74.     if temp > 0
  75.       self.contents.font.color = Color.new(82, 226, 82, 255) # 绿色
  76.     else
  77.       self.contents.font.color = Color.new(255, 255, 255, 255)
  78.     end
  79.     # ** 基本值 max
  80.     str = (max + temp).to_s
  81.     self.contents.draw_text(x + cx + 175, y, self.width - 40, @sh, str)
  82.     cx += sw(str)
  83.   end
复制代码

点评

谢啦!  发表于 2015-2-3 06:53
73行那个 dl.to_s 换成 Integer(dl).to_s 试试。  发表于 2015-2-2 21:33

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

Lv4.逐梦者

梦石
0
星屑
9275
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

2
发表于 2015-2-3 03:49:05 | 只看该作者
把73行dl后面和to_s之前加上to_i

评分

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

查看全部评分

[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 19:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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