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

Project1

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

[已经过期] 游戏停止运行

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2150
在线时间
1010 小时
注册时间
2015-10-17
帖子
1283
跳转到指定楼层
1
发表于 2020-4-5 15:14:25 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 fjm 于 2020-4-5 15:47 编辑

用了下面这个脚本,战斗时频繁出现游戏停止的提示,问下哪里出了问题,知道的指点下,谢谢


RUBY 代码复制
  1. #encoding:utf-8
  2.     #==============================================================================
  3.     # ■ Sprite_Hp
  4.     #------------------------------------------------------------------------------
  5.     #  显示血条的精灵。根据 绑定敌人 的状态自动变化。
  6.     #==============================================================================
  7.     class Sprite_Hp < Sprite
  8.       #--------------------------------------------------------------------------
  9.       # ● 初始化常量
  10.       #--------------------------------------------------------------------------
  11.       H = 36                             #位图 高度
  12.       DUR = 0.5                           #动画 持续时间
  13.       FPS = 60                            #每秒 帧数
  14.       #--------------------------------------------------------------------------
  15.       # ● 初始化对象
  16.       #--------------------------------------------------------------------------
  17.       def initialize( viewport, enemy)
  18.         super(viewport)
  19.         initPara(enemy)
  20.         create_bitmap
  21.         update
  22.       end
  23.       #--------------------------------------------------------------------------
  24.       # ● 初始化参数
  25.       #--------------------------------------------------------------------------
  26.       def initPara(enemy)
  27.         @enemy = enemy                          #绑定敌人
  28.         @colorset = [ MyColor.darkGreen, MyColor.green, MyColor.blue, MyColor.purple, MyColor.yellow] #不同管血条的颜色,可以Color.new(r,g,b,a)来设置
  29.         @life = getLife.to_i                    #获取生命数
  30.  
  31.         @tmphp = enemy.hp                       #用于动画的 临时血量
  32.         @tmpname = enemy.name              #用于敌人的 名字
  33.         @perlife = ( @life == 0 ? enemy.hp : enemy.hp/@life)           
  34.                                                 #每条命的血量
  35.         @dvalue = 0                             #临时血量差值
  36.         @ANIMA = false                          #动画状态
  37.         setPara(@enemy.enemy.note)
  38.         @nameRect = Rect.new( 0, 0, @length, 18)    #名称矩形
  39.         @bgRect = Rect.new( 0, 18, @length, 18)     #背景矩形
  40.         @hlRect = Rect.new( 4, 20, @length - 16, 8)     #高光矩形
  41.       end
  42.       #--------------------------------------------------------------------------
  43.       # ● 设置参数(通过 注释)
  44.       #--------------------------------------------------------------------------
  45.       def setPara(note)
  46.         @offsetX = (/<OFFSETX\s*(\d+)>/ =~ note ? $1.to_i : 0)
  47.         @offsetY = (/<OFFSETY\s*(\d+)>/ =~ note ? $1.to_i : -20)
  48.         @length = (/<LEN\s*(\d+)>/ =~ note ? $1.to_i : 128)
  49.         #为了绘制高光,建议设置为 8 的倍数
  50.       end
  51.       #--------------------------------------------------------------------------
  52.       # ● 释放
  53.       #--------------------------------------------------------------------------
  54.       def dispose
  55.         self.bitmap.dispose
  56.         super
  57.       end
  58.       #--------------------------------------------------------------------------
  59.       # ● 生成位图
  60.       #--------------------------------------------------------------------------
  61.       def create_bitmap
  62.         self.bitmap = Bitmap.new( @length, H)
  63.         self.bitmap.fill_rect( @bgRect, color2)     #绘制背景矩形
  64.         self.bitmap.font.size = 16
  65.         self.bitmap.font.bold = true
  66.         self.bitmap.font.italic = false
  67.         self.bitmap.font.color.set(255, 255, 255)
  68.       end
  69.       #--------------------------------------------------------------------------
  70.       # ● 底层颜色(始终填充整个矩形)
  71.       #--------------------------------------------------------------------------
  72.       def color1
  73.         if @life == 0
  74.           MyColor.darkBlue
  75.         else
  76.           @colorset[@life % @colorset.size - 1]
  77.         end
  78.       end
  79.       #--------------------------------------------------------------------------
  80.       # ● 血条颜色(变动矩形)
  81.       #--------------------------------------------------------------------------
  82.       def color2
  83.         @colorset[@life % @colorset.size ]
  84.       end
  85.       #--------------------------------------------------------------------------
  86.       # ● 获取生命条数
  87.       #--------------------------------------------------------------------------
  88.       def getLife
  89.         /<LIFE\s*(\d+)>/ =~ @enemy.enemy.note ? $1.to_s : 0
  90.       end
  91.       #--------------------------------------------------------------------------
  92.       # ● 血条长度
  93.       #--------------------------------------------------------------------------
  94.       def flexlen
  95.         if @tmphp % @perlife != 0
  96.           return (@tmphp % @perlife) * @length / @perlife
  97.         end
  98.         if (@tmphp != 0) && (@tmphp % @perlife == 0)
  99.           return @length
  100.         end
  101.       end
  102.       #--------------------------------------------------------------------------
  103.       # ● 更新画面
  104.       #--------------------------------------------------------------------------
  105.       def update
  106.         super
  107.         update_tmphp
  108.         update_life
  109.         update_bitmap
  110.         update_position
  111.         update_visibility
  112.       end
  113.       #--------------------------------------------------------------------------
  114.       # ● 更新临时血量(tmp Hp)
  115.       #--------------------------------------------------------------------------
  116.       def update_tmphp
  117.         if !@anima && (@tmphp != @enemy.hp)
  118.           @dvalue =  @tmphp - @enemy.hp
  119.           @anima = true
  120.           @tmphp = @tmphp - @dvalue/(DUR * FPS)
  121.         elsif @anima && (@tmphp == @enemy.hp)
  122.           @anima = false
  123.         elsif @anima && (@tmphp != @enemy.hp)
  124.           @tmphp = @tmphp - @dvalue/(DUR * FPS)
  125.           @tmphp = @enemy.hp if @tmphp < @enemy.hp
  126.         end
  127.       end
  128.       #--------------------------------------------------------------------------
  129.       # ● 更新命数(life)
  130.       #--------------------------------------------------------------------------
  131.       def update_life
  132.         @life = @life - 1 if @tmphp/@perlife < @life
  133.       end
  134.       #--------------------------------------------------------------------------
  135.       # ● 更新源位图(Source Bitmap)
  136.       #--------------------------------------------------------------------------
  137.       def update_bitmap
  138.         redraw
  139.       end
  140.       #--------------------------------------------------------------------------
  141.       # ● 重绘
  142.       #--------------------------------------------------------------------------
  143.       def redraw
  144.         self.bitmap.clear
  145.  
  146.         self.bitmap.fill_rect( @bgRect, color1)     #绘制背景矩形
  147.         self.bitmap.fill_rect( @bgRect.x, @bgRect.y, flexlen, @bgRect.height, color2) if @tmphp != 0
  148.                                                     #绘制血条矩形
  149.         self.bitmap.draw_border( @bgRect, MyColor.darkBlue, 2)
  150.         #绘制边框
  151.         draw_highlight( @hlRect)
  152.         #绘制高光
  153.         self.bitmap.draw_text(self.bitmap.rect, life_text, 2) if @life != 0  
  154.         #绘制生命数(当生命数不为0)
  155.         self.bitmap.draw_text(@bgRect, @tmphp.to_i.to_s, 1)
  156.         #绘制生命值
  157.         self.bitmap.draw_text(0, 0, 120, 24, @tmpname)
  158.         #绘制敌人名字
  159.       end
  160.       #--------------------------------------------------------------------------
  161.       # ● 绘制高光
  162.       #--------------------------------------------------------------------------
  163.       def draw_highlight( dest_rect)
  164.         leftCorner = Rect.new(0,0,8,8)
  165.         middle = Rect.new(8,0,8,8)
  166.         rightCorner = Rect.new(16,0,8,8)
  167.         pic = Cache.picture("hightLight01")
  168.         x = dest_rect.x
  169.         y = dest_rect.y
  170.         i = 1
  171.         self.bitmap.stretch_blt(Rect.new( x, y, 8, 8), pic, leftCorner)
  172.         while x < (dest_rect.x + dest_rect.width - 8)
  173.           x = x + 8
  174.           self.bitmap.stretch_blt(Rect.new( x, y, 8, 8), pic, middle)
  175.         end
  176.         x = x + 8
  177.         self.bitmap.stretch_blt(Rect.new( x, y, 8, 8), pic, rightCorner)
  178.       end
  179.       #--------------------------------------------------------------------------
  180.       # ● 生成绘制内容
  181.       #--------------------------------------------------------------------------
  182.       def life_text
  183.         sprintf("x%2d", @life)
  184.       end
  185.       #--------------------------------------------------------------------------
  186.       # ● 更新位置
  187.       #--------------------------------------------------------------------------
  188.       def update_position
  189.         self.x = @enemy.screen_x - self.bitmap.width/2 + @offsetX-125 #血条位置
  190.         self.y = @enemy.screen_y + @offsetY -20                                  #血条位置
  191.         self.z = 200
  192.       end
  193.       #--------------------------------------------------------------------------
  194.       # ● 更新可视状态
  195.       #--------------------------------------------------------------------------
  196.       def update_visibility
  197.         self.visible = true if @enemy.hp != 0
  198.         self.visible = false if (@enemy.hp == 0) && !@anima
  199.       end
  200.     end
  201.     #encoding:utf-8
  202.     #==============================================================================
  203.     # ■ Spriteset_Battle
  204.     #------------------------------------------------------------------------------
  205.     #  处理战斗画面的精灵的类。本类在 Scene_Battle 类的内部使用。
  206.     #==============================================================================
  207.     class Spriteset_Battle
  208.       #--------------------------------------------------------------------------
  209.       # ● 初始化对象
  210.       #--------------------------------------------------------------------------
  211.       def initialize
  212.         create_viewports
  213.         create_battleback1
  214.         create_battleback2
  215.         create_enemies
  216.         create_actors
  217.         create_pictures
  218.         create_timer
  219.         create_hp
  220.         update
  221.       end
  222.       #--------------------------------------------------------------------------
  223.       # ● Hp 精灵生成
  224.       #--------------------------------------------------------------------------
  225.       def create_hp
  226.         @hp_sprites = $game_troop.members.reverse.collect do |enemy|
  227.           Sprite_Hp.new(@viewport1, enemy)
  228.         end
  229.       end
  230.       #--------------------------------------------------------------------------
  231.       # ● 更新画面
  232.       #--------------------------------------------------------------------------
  233.       def update
  234.         update_battleback1
  235.         update_battleback2
  236.         update_enemies
  237.         update_actors
  238.         update_pictures
  239.         update_timer
  240.         update_hp
  241.         update_viewports
  242.       end
  243.       #--------------------------------------------------------------------------
  244.       # ● 更新敌人的精灵
  245.       #--------------------------------------------------------------------------
  246.       def update_hp
  247.         @hp_sprites.each {|sprite| sprite.update }
  248.       end
  249.     end
  250.     #encoding:utf-8
  251.     #==============================================================================
  252.     # ■ Bitmap_extension
  253.     #------------------------------------------------------------------------------
  254.     #  Bitmap类的扩展
  255.     #==============================================================================
  256.     class Bitmap
  257.       #--------------------------------------------------------------------------
  258.       # ● 绘制边框
  259.       #--------------------------------------------------------------------------
  260.       def draw_border( x, y, width, height, color, thick)
  261.         self.fill_rect( x, y, width, thick, color)
  262.         self.fill_rect( x + width - thick, y, thick, height, color)
  263.         self.fill_rect( x, y + height - thick, width, thick, color)
  264.         self.fill_rect( x, y, thick, height, color)
  265.       end
  266.       #--------------------------------------------------------------------------
  267.       # ● 绘制边框 参数为 Rect
  268.       #--------------------------------------------------------------------------
  269.       def draw_border( rect, color, thick)
  270.         self.fill_rect( rect.x, rect.y, rect.width, thick, color)
  271.         self.fill_rect( rect.x + rect.width - thick, rect.y, thick, rect.height, color)
  272.         self.fill_rect( rect.x, rect.y + rect.height - thick, rect.width, thick, color)
  273.         self.fill_rect( rect.x, rect.y, thick, rect.height, color)
  274.       end
  275.     end
  276.     #encoding:utf-8
  277.     #==============================================================================
  278.     # ■ Color_extension
  279.     #------------------------------------------------------------------------------
  280.     #  mColor类,包含常用色
  281.     #==============================================================================
  282.     class MyColor
  283.       #--------------------------------------------------------------------------
  284.       # ● 常用的颜色
  285.       #--------------------------------------------------------------------------
  286.       def self.black   ; Color.new(   0,   0,   0)   end
  287.       def self.white   ; Color.new( 255, 255, 255)   end
  288.       def self.red     ; Color.new( 255,   0,   0)   end
  289.       def self.green   ; Color.new(   0, 255,   0)   end
  290.       def self.blue    ; Color.new(   0,   0, 255)   end
  291.       def self.gray    ; Color.new( 128, 128, 128)   end
  292.       def self.yellow  ; Color.new( 255, 255,   0)   end
  293.       def self.purple  ; Color.new( 255,   0, 255)   end
  294.       def self.darkRed ; Color.new( 128,   0,   0)   end
  295.       def self.darkGreen;Color.new(   0, 128,   0)   end
  296.       def self.darkBlue; Color.new(   0,   0, 128)   end
  297.       def self.lighRed ; Color.new( 255, 128, 128)   end
  298.     end

8888.png (12.53 KB, 下载次数: 17)

8888.png

Lv4.逐梦者

梦石
3
星屑
7095
在线时间
589 小时
注册时间
2019-9-15
帖子
113

R考场第七期金奖

2
发表于 2020-4-5 18:00:28 | 只看该作者
那个。。运行这段脚本需要Graphics\Pictures\hightLight01文件 如果没有的话只能删掉其中一段脚本了
到时候测试的结果可能会不准确  可以麻烦LZ发一下这个文件或者整个的报错工程嘛
********
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2150
在线时间
1010 小时
注册时间
2015-10-17
帖子
1283
3
 楼主| 发表于 2020-4-5 20:31:28 | 只看该作者
本帖最后由 fjm 于 2020-4-5 20:33 编辑
Cupidk爱呗茶 发表于 2020-4-5 18:00
那个。。运行这段脚本需要Graphics\Pictures\hightLight01文件 如果没有的话只能删掉其中一段脚本了
到时 ...


这个脚本我找的,就一个脚本,我弄了张图片,改成这个名字就凑合用了

要是这个脚本没问题的话,估计和其他脚本冲突了,我排查下,看看和哪个脚本起冲突了
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
3
星屑
7095
在线时间
589 小时
注册时间
2019-9-15
帖子
113

R考场第七期金奖

4
发表于 2020-4-5 20:36:45 | 只看该作者
fjm 发表于 2020-4-5 20:31
这个脚本我找的,就一个脚本,我弄了张图片,改成这个名字就凑合用了

要是这个脚本没问题的话,估计和其 ...

我稍微测了一下战斗好像暂时没有发现什么问题。。 可以讲一下错误是怎么触发的嘛
********
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2150
在线时间
1010 小时
注册时间
2015-10-17
帖子
1283
5
 楼主| 发表于 2020-4-5 20:46:33 | 只看该作者
Cupidk爱呗茶 发表于 2020-4-5 20:36
我稍微测了一下战斗好像暂时没有发现什么问题。。 可以讲一下错误是怎么触发的嘛 ...

战斗的时候触发的错误,我删掉了两个脚本,现在测试了10分钟也没发生过这个错误,我再试试
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-24 23:09

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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