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

Project1

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

[原创发布] 【新版伤害美化】波形跳动显示时尚版(图片数字)

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
98 小时
注册时间
2012-7-12
帖子
57
跳转到指定楼层
1
发表于 2012-8-4 20:10:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 っ盛尘、恋 于 2012-8-30 08:01 编辑

发现一个BUG,使用解除状态的技能会出现MISS图片,现在已经解决,已经使用过的可以直接更新,(大概在64行,102行,150行有改动)
———————————————————————————————————————————————————————————————————————————
我找遍了很多地方也没看有伤害这样显示的,所以研究了下,可能比较时尚哦。刚做出来,可暂时称为1.0测试版,脚本可能不够简洁,感兴趣的可以帮忙简化一下,感谢了!
另外,不知道有没有BUG,用了很久还没发现,如果有发现的话,还请提出来噢。因为这个是图片版的,考虑到有些新手可能没有数字图片,所以范例工程带了图片,可以直接使用。


下面是实现的效果:
比如,伤害为 236  , 2先出来跳到最高点,此时3跳动到了最高点的一半,6刚好出来,当2再次回到原来的位置时,3从最高点到了一半的位置,6到了最高点的位置。然后2不动,3和6陆续回到原来的位置。

效果:



使用说明:
FMS = 2    # 第一次移动的速度
  Num = 3    # 第二第三次移动的速度
  XS = 15    # 第二次移动的像素
  XT = 9     # 第三次移动的像素
  NU = 10   # 数字间的间距 ps:它的三倍也是第一次移动的距离
  FNH = 30   # 第一个数字的高度 这个别乱改,改动了其他坐标也要改
  MAX_D = 70 # 显示的时间的最大值.
准备三张图片放在Pictures文件夹里,会心一击图片大小为:200 X 28 , 恢复图片和普通伤害图片为150 X 21 ,数字从0排到9,MISS图片为 55 X 20 修改在代码的80到105行之间

改上面着些数字的时候一定要把握好NU、FMS、Num、MAX_D这些数值之间的配合,详细的就不说了,大家改改试试效果就知道了。

测试工程:http://115.com/file/anbhygbu#Project.zip

把下面的脚本代码直接插入Main的前面,

  1. # 转载请注明出处————666RPG-盛尘恋-修改制作———————————————
  2. #——————————————————————————————————————
  3. module RPG
  4. #——————————————————————————————————————
  5. # 初始化数值
  6.   FMS = 2    # 第一次移动的速度
  7.   Num = 3    # 第二第三次移动的速度
  8.   XS = 15    # 第二次移动的像素
  9.   XT = 9     # 第三次移动的像素
  10.   NU = 10   # 数字间的间距 ps:它的三倍也是第一次移动的距离
  11.   FNH = 30   # 第一个数字的高度
  12.   MAX_D = 65 # 显示的时间的最大值
  13. #——————————————————————————————————————

  14. class Sprite < ::Sprite
  15. #--------------------------------------------------------------------------
  16. # ● 初始化对像
  17. #--------------------------------------------------------------------------
  18. def initialize(viewport = nil)
  19.       super(viewport)
  20.       @_whiten_duration = 0
  21.       @_appear_duration = 0
  22.       @_escape_duration = 0
  23.       @_collapse_duration = 0
  24.       @_damage_duration = 0
  25.       @_animation_duration = 0
  26.       @_damage_show = false
  27.       @_blink = false
  28. end
  29. #--------------------------------------------------------------------------
  30. # ● 伤害
  31. #--------------------------------------------------------------------------
  32. def damage(value, critical)
  33.      
  34.       # 释放伤害及转化变量
  35.       dispose_damage
  36.       @value = value
  37.       @critical = critical
  38.   
  39.       # 伤害值定位
  40.       @_damage_sprite = ::Sprite.new(self.viewport)
  41.       @_damage_sprite.bitmap = Bitmap.new(200, 100)
  42.       @_damage_show = true
  43.       
  44.       @_damage_sprite.ox = 0
  45.       @_damage_sprite.oy = 0
  46.       @_damage_sprite.x = self.x - 82
  47.       x1 = (self.bitmap.width-self.bitmap.width/4)/2
  48.       @_damage_sprite.x -= x1 - 10 if @battler.is_a?(Game_Actor)
  49.       
  50.       @_damage_sprite.y = self.y - self.oy - 30
  51.       @_damage_sprite.y += self.oy/2-45 if @battler.is_a?(Game_Actor)
  52.       @_damage_sprite.z = 3000
  53.       
  54.       # 与移动有关的变量初始化
  55.       @_damage_duration = MAX_D
  56.       @_damage_nb1t = []
  57.       @_damage_rect = []
  58.       @_damage_nb1t[0] = FNH - 3*NU
  59.       @_damage_nb1t[1] = FNH - 2*NU
  60.       @_damage_nb1t[2] = FNH - NU
  61.       @_damage_nb1t[3] = FNH
  62.       @XV = 3*NU / FMS
  63.       @XE = 2*NU / FMS
  64.       @XR = NU / FMS
  65.       if @value.is_a?(Numeric)
  66.         damage_string = @value.abs.to_s
  67.       else
  68.         # 转为字符串
  69.         damage_string = @value.to_s
  70.       end
  71.       @damage_string = damage_string
  72.       # 如果是数值的情况下
  73.       if value.is_a?(Numeric)        
  74.         @_damage_x = 80 - damage_string.size * 9
  75.         @ax = 0
  76.         @ay = 0
  77.         # 分割
  78.         damage_array = damage_string.split(//)
  79.         for i in 0...damage_array.size
  80.           damage_array[i] = damage_array[i].to_i
  81.         end
  82.         
  83.         # 会心一击的情况下
  84.         if @critical == true
  85.           @_damage_bmp = Bitmap.new("Graphics/Pictures/white_Number_l")
  86.           for i in 0...damage_array.size
  87.             @_damage_rect[i] = Rect.new(damage_array[i] * 20, 0, 20, 28)
  88.           end
  89.          
  90.         #其他情况,包括恢复
  91.         else
  92.            if value < 0
  93.               @_damage_bmp = Bitmap.new("Graphics/Pictures/green_Number_m")
  94.            else
  95.               @_damage_bmp = Bitmap.new("Graphics/Pictures/white_Number_m")
  96.            end
  97.            for i in 0...damage_array.size
  98.             @_damage_rect[i] = Rect.new(damage_array[i] * 15, 0, 15, 21)
  99.            end
  100.         end
  101.       
  102.       #不是数值的情况
  103.       elsif value == "Miss"
  104.         @_damage_bmp = Bitmap.new("Graphics/Pictures/miss1")
  105.       end
  106.   end
  107. #--------------------------------------------------------------------------
  108. # ● 刷新画面
  109. #--------------------------------------------------------------------------
  110. def update
  111.    super
  112.    if @_whiten_duration > 0
  113.      @_whiten_duration -= 1
  114.      self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  115.    end
  116.    if @_appear_duration > 0
  117.      @_appear_duration -= 1
  118.      self.opacity = (16 - @_appear_duration) * 16
  119.    end
  120.    if @_escape_duration > 0
  121.      @_escape_duration -= 1
  122.    self.opacity = 256 - (32 - @_escape_duration) * 10
  123.    end
  124.    if @_collapse_duration > 0
  125.      @_collapse_duration -= 1
  126.    self.opacity = 256 - (48 - @_collapse_duration) * 6
  127.    end

  128.    #——————————————————————————————————————         
  129.    # 以下为伤害显示部分
  130.    #——————————————————————————————————————
  131.    if @_damage_show == true
  132.      @_damage_sprite.bitmap.clear
  133.      if @value.is_a?(Numeric)
  134.        if @critical == true
  135.          for i in 0...@_damage_rect.size
  136.            @_damage_nb1t[i+4] = @_damage_nb1t[i]
  137.             ay = @_damage_nb1t[i]
  138.             ax = @_damage_x+i*22
  139.            @_damage_sprite.bitmap.blt(ax, ay, @_damage_bmp, @_damage_rect[i])
  140.          end
  141.        else
  142.          for i in 0...@_damage_rect.size
  143.            @_damage_nb1t[i+4] = @_damage_nb1t[i]
  144.             ay = @_damage_nb1t[i]
  145.             ax = @_damage_x+i*17
  146.            @_damage_sprite.bitmap.blt(ax, ay, @_damage_bmp, @_damage_rect[i])
  147.          end
  148.         end
  149.       else
  150.         unless @value == "Miss"
  151.              # 系统默认描画字符串

  152.           @_damage_sprite.bitmap.font.color.set(0, 0, 0)

  153.           @_damage_sprite.bitmap.draw_text(-1, 27, 162, 36, @damage_string, 1)

  154.           @_damage_sprite.bitmap.draw_text(+1, 27, 162, 36, @damage_string, 1)

  155.           @_damage_sprite.bitmap.draw_text(-1, 29, 162, 36, @damage_string, 1)

  156.           @_damage_sprite.bitmap.draw_text(+1, 29, 162, 36, @damage_string, 1)

  157.           @_damage_sprite.bitmap.font.color.set(255, 255, 255)

  158.           @_damage_sprite.bitmap.draw_text(0, 28, 162, 36, @damage_string, 1)
  159.         else
  160.          @_damage_sprite.bitmap.blt(45, @_damage_nb1t[1], @_damage_bmp, Rect.new(0, 0, 55, 20))
  161.         end
  162.       
  163.      end
  164.      
  165.    if @_damage_duration > 0
  166.     @_damage_duration -= 1
  167. #————————————————移动代码部分———————————————————
  168.     if MAX_D-@XV <= @_damage_duration and @_damage_duration < MAX_D      
  169.        @_damage_nb1t[3] -= FMS
  170.     elsif MAX_D-2*@XV <= @_damage_duration and @_damage_duration < MAX_D-@XV                                
  171.        @_damage_nb1t[3] += FMS
  172.     elsif MAX_D-2*@XV-XS/Num <= @_damage_duration and @_damage_duration < MAX_D-2*@XV
  173.        @_damage_nb1t[3] -= Num
  174.     elsif MAX_D-2*@XV-2*XS/Num <= @_damage_duration and @_damage_duration < MAX_D-2*@XV-XS/Num
  175.        @_damage_nb1t[3] += Num
  176.     elsif MAX_D-2*@XV-2*XS/Num-XT/Num <= @_damage_duration and @_damage_duration < MAX_D-2*@XV-2*XS/Num
  177.        @_damage_nb1t[3] -= Num
  178.     elsif MAX_D-2*@XV-2*XS/Num-2*XT/Num <= @_damage_duration and @_damage_duration < MAX_D-2*@XV-2*XS/Num-XT/Num
  179.        @_damage_nb1t[3] += Num
  180.     else
  181.        @_damage_nb1t[3] += 0
  182.     end
  183.    

  184.     if MAX_D-@XV <= @_damage_duration and @_damage_duration < MAX_D
  185.        @_damage_nb1t[0] += FMS
  186.     elsif MAX_D-@XV-XS/Num <= @_damage_duration and @_damage_duration < MAX_D-@XV
  187.        @_damage_nb1t[0] -= Num
  188.     elsif MAX_D-@XV-2*XS/Num <= @_damage_duration and @_damage_duration < MAX_D-@XV-XS/Num
  189.        @_damage_nb1t[0] += Num
  190.     elsif MAX_D-@XV-2*XS/Num-XT/Num <= @_damage_duration and @_damage_duration < MAX_D-@XV-2*XS/Num
  191.        @_damage_nb1t[0] -= Num
  192.     elsif MAX_D-@XV-2*XS/Num-2*XT/Num <= @_damage_duration and @_damage_duration < MAX_D-@XV-2*XS/Num-XT/Num
  193.        @_damage_nb1t[0] += Num
  194.     else
  195.        @_damage_nb1t[0] -= 0
  196.     end

  197.     if MAX_D-@XR <= @_damage_duration and @_damage_duration < MAX_D
  198.        @_damage_nb1t[1] -= FMS
  199.     elsif MAX_D-@XR-@XV <= @_damage_duration and @_damage_duration < MAX_D-@XR
  200.        @_damage_nb1t[1] += FMS
  201.     elsif MAX_D-@XR-@XV-XS/Num <= @_damage_duration and @_damage_duration < MAX_D-@XR-@XV
  202.        @_damage_nb1t[1] -= Num
  203.     elsif MAX_D-@XR-@XV-2*XS/Num <= @_damage_duration and @_damage_duration < MAX_D-@XR-@XV-XS/Num
  204.        @_damage_nb1t[1] += Num
  205.     elsif MAX_D-@XR-@XV-2*XS/Num-XT/Num <= @_damage_duration and @_damage_duration < MAX_D-@XR-@XV-2*XS/Num
  206.        @_damage_nb1t[1] -= Num
  207.     elsif MAX_D-@XR-@XV-2*XS/Num-2*XT/Num <= @_damage_duration and @_damage_duration < MAX_D-@XR-@XV-2*XS/Num-XT/Num
  208.        @_damage_nb1t[1] += Num
  209.     else
  210.        @_damage_nb1t[1] -= 0
  211.     end
  212.    
  213.     if MAX_D-@XE <= @_damage_duration and @_damage_duration < MAX_D
  214.        @_damage_nb1t[2] -= FMS
  215.     elsif MAX_D-@XE-@XV <= @_damage_duration and @_damage_duration < MAX_D-@XE
  216.        @_damage_nb1t[2] += FMS
  217.     elsif MAX_D-@XE-@XV-XS/Num <= @_damage_duration and @_damage_duration < MAX_D-@XE-@XV
  218.        @_damage_nb1t[2] -= Num
  219.     elsif MAX_D-@XE-@XV-2*XS/Num <= @_damage_duration and @_damage_duration < MAX_D-@XE-@XV-XS/Num
  220.        @_damage_nb1t[2] += Num
  221.     elsif MAX_D-@XE-@XV-2*XS/Num-XT/Num <= @_damage_duration and @_damage_duration < MAX_D-@XE-@XV-2*XS/Num
  222.        @_damage_nb1t[2] -= Num
  223.     elsif MAX_D-@XE-@XV-2*XS/Num-2*XT/Num <= @_damage_duration and @_damage_duration < MAX_D-@XE-@XV-2*XS/Num-XT/Num
  224.        @_damage_nb1t[2] += Num
  225.     else
  226.        @_damage_nb1t[2] += 0
  227.     end
  228. #-----------------------------------------------------------------------------
  229.   end

  230.    @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
  231.    if @_damage_duration == 0
  232.       @_damage_sprite.bitmap.dispose
  233.       @_damage_sprite.dispose
  234.       if @_damage_bmp != nil
  235.          @_damage_bmp.dispose
  236.       end
  237.       @_damage_show = false
  238.    end
  239.   end
  240.   if @_animation != nil and (Graphics.frame_count % 2 == 0)
  241.      @_animation_duration -= 1
  242.      update_animation
  243.   end
  244.   if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  245.      update_loop_animation
  246.      @_loop_animation_index += 1
  247.      @_loop_animation_index %= @_loop_animation.frame_max
  248.   end
  249.   if @_blink
  250.     @_blink_count = (@_blink_count + 1) % 32
  251.     if @_blink_count < 16
  252.       alpha = (16 - @_blink_count) * 6
  253.     else
  254.       alpha = (@_blink_count - 16) * 6
  255.     end
  256.     self.color.set(255, 255, 255, alpha)
  257.   end
  258.   @@_animations.clear
  259. end
  260. def dispose_damage
  261.    if @_damage_sprite != nil
  262.       @_damage_sprite.bitmap.dispose
  263.       @_damage_sprite.dispose
  264.       @_damage_sprite = nil
  265.       @_damage_duration = 0
  266.    end
  267.    if @_damage_bmp != nil
  268.       @_damage_bmp.dispose
  269.    end
  270.    @_damage_show = false
  271. end
  272. end
  273. end
  274. # 转载请注明出处————666RPG-盛尘恋-修改制作———————————————
复制代码

Lv2.观梦者 (版主)

迷途知返,恍如隔世

梦石
0
星屑
488
在线时间
1355 小时
注册时间
2011-2-17
帖子
1216

开拓者

2
发表于 2012-8-28 18:29:15 | 只看该作者
这效果真是太棒了=W=
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
111
在线时间
1421 小时
注册时间
2008-8-30
帖子
999
3
发表于 2012-8-28 18:39:14 | 只看该作者
节奏快的游戏没法用吧,感觉慢悠悠的
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
98 小时
注册时间
2012-7-12
帖子
57
4
 楼主| 发表于 2012-8-30 07:52:37 | 只看该作者
jklpgh 发表于 2012-8-28 18:39
节奏快的游戏没法用吧,感觉慢悠悠的

呵呵,那里有参数,可以自己调呢
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-30 10:22

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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