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

Project1

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

[已经解决] 经验条显示异常

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3181
在线时间
1863 小时
注册时间
2010-6-19
帖子
1205
跳转到指定楼层
1
发表于 2022-5-12 23:14:35 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
在脚本里加入了一个经验条显示的功能,但是发现关闭窗口的时候,经验条还会显示在地图上,等几秒才消失,不知道啥情况。。。






如图BUG


RUBY 代码复制
  1. #==============================================================================
  2. # ■ JD_DL
  3. #------------------------------------------------------------------------------
  4. #  显示加点状态窗口。
  5. #==============================================================================
  6.  
  7. class JD_DL < Window_Base
  8.   #--------------------------------------------------------------------------
  9.   # ● 初始化对像
  10.   #     actor : 角色
  11.   #--------------------------------------------------------------------------
  12.   def initialize(actor)
  13.     super(160+300, 100, 480, 320)
  14.     self.contents = Bitmap.new(width - 32, height - 32)
  15.     self.contents.font.size = 16
  16.     @actor = actor
  17.     # 文字高
  18.     # 可以放在refresh里 实时控制
  19.     @sh = 32
  20.     refresh
  21.   end  
  22.   #--------------------------------------------------------------------------
  23.   # ● 刷新
  24.   #--------------------------------------------------------------------------
  25.   def refresh
  26.     self.contents.clear
  27.     draw_actor_face(@actor, 0, 0)         # 头像
  28.     draw_actor_name_duiwu(@actor, 20, 0)  # 名字
  29.     draw_actor_level(@actor, 20, 32)      # 等级
  30.     draw_v(0, 32*2, 0)                    # 气血
  31.     draw_v(0, 32*3, 1)                    # 法力
  32.     draw_dl(0, 32*4, 0)                   # 力量
  33.     draw_dl(0, 32*5, 1)                   # 魔力
  34.     draw_dl(0, 32*6, 2)                   # 速度
  35.     draw_dl(0, 32*7, 3)                   # 灵巧
  36.     # 潜力描绘
  37.     self.contents.font.color = system_color
  38.     str = "潜力"
  39.     self.contents.draw_text(0, 32*8, sw(str), @sh, str) # 潜力
  40.     cx = sw(str)
  41.     # ** 调整颜色
  42.     if $point != @actor.qianli
  43.       self.contents.font.color = text_color(6)
  44.     else
  45.       self.contents.font.color = normal_color
  46.     end
  47.     # 潜力数值描绘
  48.     self.contents.draw_text(cx + 10, 32*8, sw($point.to_s), @sh, $point.to_s) #数值
  49.     # 描绘经验条
  50.     self.contents.font.color = normal_color
  51.     self.contents.draw_text(100, 235, 300, 32, @actor.exp_s + "/" + @actor.next_exp_s)
  52.     #--------经验条显示------------------------------------------------------  
  53.     @exp_a = nil
  54.     @exp_b = nil   
  55.     @exp_a = Sprite.new
  56.     @exp_b = Sprite.new  
  57.     #--------经验条窗口显示--------------------------------------------------
  58.     @exp_a.bitmap = Bitmap.new(168,10)     #(经验条1宽度,第高度)
  59.     @exp_b.bitmap = Bitmap.new(168,5)      #(经验条2宽度,第高度)
  60.     #--------经验条颜色------------------------------------------------------
  61.     color1 = Color.new(111,172,115,255)  #经验条1颜色
  62.     color2 = Color.new(49,159,51,255)    #经验条2颜色
  63.     #--------经验值增幅度----------------------------------------------------
  64.     next_exp = @actor.next_exp_s.to_i == 0 ? @actor.exp : @actor.next_exp_s.to_i
  65.     @exp_d = 168*@actor.exp/next_exp
  66.     #--------经验条增幅条1---------------------------------------------------
  67.     @exp_a.x = 576
  68.     @exp_a.y = 380
  69.     @exp_a.z = 1000
  70.     @exp_a.bitmap.fill_rect(0,0,@exp_d,32,color1)
  71.     #--------经验条增幅条2---------------------------------------------------
  72.     @exp_b.x = 576
  73.     @exp_b.y = 383
  74.     @exp_b.z = 1000
  75.     @exp_b.bitmap.fill_rect(0,0,@exp_d,32,color2)
  76.     end
  77.     #--------释放经验条------------------------------------------------------
  78.     def dispose
  79.     super   
  80.     @exp_a.bitmap.dispose  
  81.     @exp_b.bitmap.dispose  
  82.     @exp_a.dispose   
  83.     @exp_b.dispose
  84.     @exp_a = nil
  85.     @exp_b = nil  
  86.     #------------------------------------------------------------------------   
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   #  **  属性描绘
  90.   #--------------------------------------------------------------------------
  91.   # ** 返回字符串的宽度
  92.   def sw(s)
  93.     return self.contents.text_size(s).width
  94.   end
  95.   # ** HP AND SP 描绘
  96.   def draw_v(x, y, type)
  97.     case type
  98.     when 0
  99.       word = $data_system.words.hp
  100.       dl = @actor.hp
  101.       max = @actor.maxhp
  102.       temp = $temp_hp
  103.     when 1
  104.       word = $data_system.words.sp
  105.       dl = @actor.sp
  106.       max = @actor.maxsp
  107.       temp = $temp_sp
  108.     else
  109.       return
  110.     end
  111.     self.contents.font.color = system_color
  112.     # ** 用语
  113.     str = word
  114.     self.contents.draw_text(x, y, sw(str), @sh, str)
  115.     self.contents.font.color = normal_color
  116.     # ** 基本值
  117.     cx = sw(str)
  118.     str = dl.to_s + "/"
  119.     self.contents.draw_text(x + cx + 10, y, sw(str), @sh, str)
  120.     cx += sw(str)
  121.     # ** 调整颜色
  122.     if temp > 0
  123.       self.contents.font.color = text_color(6)
  124.     else
  125.       self.contents.font.color = normal_color
  126.     end
  127.     # ** 基本值 max
  128.     str = (max + temp).to_s
  129.     self.contents.draw_text(x + cx + 10, y, sw(str), @sh, str)
  130.     cx += sw(str)
  131.     # ** 附加值
  132.     if temp > 0
  133.       self.contents.font.color.set(255, 100, 100)
  134.       str = "(+" + temp.to_s + ")"
  135.       self.contents.draw_text(x + cx + 10, y, sw(str), @sh, str)
  136.     end
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   #  **  属性描绘
  140.   #--------------------------------------------------------------------------
  141.   def draw_dl(x, y, type)
  142.     # ** 准备描绘
  143.     case type
  144.     when 0
  145.       word = $data_system.words.str
  146.       dl = @actor.str
  147.       plus = $temp_str
  148.     when 1
  149.       word = $data_system.words.int
  150.       dl = @actor.int
  151.       plus = $temp_int
  152.     when 2
  153.       word = $data_system.words.agi
  154.       dl = @actor.agi
  155.       plus = $temp_agi
  156.     when 3
  157.       word = $data_system.words.dex
  158.       dl = @actor.dex
  159.       plus = $temp_dex
  160.     else
  161.       return
  162.     end
  163.     # ** 开始描绘
  164.     self.contents.font.color = system_color
  165.     # ** 用语
  166.     str = word
  167.     self.contents.draw_text(x, y, sw(str), @sh, str)
  168.     # ** 设置新值颜色
  169.     if plus > 0
  170.       self.contents.font.color = text_color(6)
  171.     else
  172.       self.contents.font.color = normal_color
  173.     end
  174.     # ** 基本值
  175.     cx = sw(str)
  176.     str = (dl + plus).to_s
  177.     self.contents.draw_text(x + cx + 10, y, sw(str), @sh, str)
  178.     cx += sw(str)
  179.     # ** 附加值
  180.     if plus > 0
  181.       self.contents.font.color.set(255, 100, 100)
  182.       str = "(+" + plus.to_s + ")"
  183.       self.contents.draw_text(x + cx + 10, y, sw(str), @sh, str)
  184.     end
  185.   end
  186. end

Lv5.捕梦者 (版主)

梦石
1
星屑
23963
在线时间
3338 小时
注册时间
2011-7-8
帖子
3925

开拓者

2
发表于 2022-5-13 00:46:18 | 只看该作者
看上去脚本没有问题,可能是你调用的时候忘记了主动 dispose。
你找一下自己写@x = JD_DL.new之后是不是忘了写@x.dispose
熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6483
在线时间
119 小时
注册时间
2020-1-8
帖子
234
3
发表于 2022-5-13 07:21:18 | 只看该作者
你的经验条可以直接描绘在self.contents上,当然用精灵可以避免重复描绘

refresh里重新生成经验条精灵及其位图...,多次调用refresh的话原先生成精灵及其位图并没有释放。
用精灵的话,建议在intialize里生成,并用个实例变量记录具体数据,数据不同的话,再在refresh里对其位图进行重绘等

评分

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

查看全部评分

回复 支持 反对

使用道具 举报

Lv5.捕梦者 (版主)

梦石
1
星屑
23963
在线时间
3338 小时
注册时间
2011-7-8
帖子
3925

开拓者

4
发表于 2022-5-13 14:12:43 | 只看该作者
本帖最后由 guoxiaomi 于 2022-5-13 14:13 编辑
RPGzh500223 发表于 2022-5-13 07:21
你的经验条可以直接描绘在self.contents上,当然用精灵可以避免重复描绘

refresh里重新生成经验条精灵及其 ...


原来如此,那他只要在53行前面加上
  1. @exp_a.dispose if @exp_a
  2. @exp_b.dispose if @exp_b
  3. @exp_a = nil
  4. @exp_b = nil
复制代码

评分

参与人数 1星屑 +50 收起 理由
RyanBern + 50 我很赞同

查看全部评分

熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-24 22:37

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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