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

Project1

 找回密码
 注册会员
搜索
查看: 2361|回复: 1

[已经过期] 改了一下碎屏转场脚本,出现内存错误

[复制链接]

Lv1.梦旅人

梦石
0
星屑
49
在线时间
491 小时
注册时间
2012-1-27
帖子
421

整合系统大赛RMVA达人

发表于 2012-12-5 16:55:15 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 狱冥幻翼 于 2012-12-5 16:57 编辑

原版的碎屏脚本计算量太大了,就自己改了改,不过连续两次战斗后会提示内存错误,求解~改了74-91行
改后的脚本↓
  1. class Broken_Screen
  2.   #--------------------------------------------------------------------------
  3.   # ● 初始化对象
  4.   #--------------------------------------------------------------------------

  5.   def initialize(filename="Graphics/system/sptx.png")
  6.     @width = Graphics.width  #获取宽高
  7.     [url=home.php?mod=space&uid=291977]@height[/url] = Graphics.height
  8.     #===========================
  9.     @step_w = @width/2  #★★★★★★★★★★★#★★★★★★★★★★★
  10.     @step_h = @height/2 #★★★★★★★★★★★#★★★★★★★★★★★
  11.     #可以设置这两项数据,以减少可能会出现的误差,
  12.     #因为脚本并不会检查所有的像素,所以有时候会出现误差,减少
  13.     #步长可以减少出现误差的可能,但会增加计算量。
  14.     #===========================
  15.     @picture = Graphics.snap_to_bitmap #获取当前的图像
  16.     @borken_pic = Bitmap.new(filename)#获取破碎辅助图
  17.     @shards = {} #碎片的数组
  18.     start #开始绘图
  19.   end
  20.   #--------------------------------------------------------------------------
  21.   # ● 开始绘图
  22.   #--------------------------------------------------------------------------
  23.   def start
  24.     make_shard
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 开始炸开
  28.   #--------------------------------------------------------------------------
  29.   def get_bomb
  30.     Audio.se_play("Audio/SE/crash")
  31.     temp = [] #将哈希表转换为数组
  32.     @shards.each_value{|shard|
  33.     temp.push shard
  34.     }
  35.     @shards = temp
  36.     shards_v = []
  37.    
  38.     for i in [email protected]
  39.       #               对象         中心位置                            转速
  40.       @shards[i].angle=rand(2)*45
  41.       shards_v.push [@shards[i],rand(@shards[i].x)+20-rand(40),@shards[i].y-208,rand(2)]
  42.     end
  43.     for t in 0..89
  44.       for sha in shards_v
  45.         sha[0].x+= sha[1]/10
  46.         sha[0].y+= sha[2]/20
  47. #~         msgbox sha[0].x
  48.         sha[2]+=10
  49.           sha[0].angle+=sha[3]
  50.         if sha[3] == 0
  51.           sha[0].zoom_x -= 0.01
  52.          
  53.         else
  54.           sha[0].zoom_y -= 0.01
  55.          
  56.         end
  57.          
  58.       end
  59.       Graphics.update

  60.     end
  61.     for sha in shards_v
  62.       sha[0].dispose
  63.     end
  64.     @picture.dispose
  65.     @borken_pic.dispose
  66.   end

  67.   #--------------------------------------------------------------------------
  68.   # ● 制作碎片
  69.   # area,可以被绘图的区域
  70.   #--------------------------------------------------------------------------
  71.   def make_shard
  72.     area = [1,1,300,200]
  73.     spr = Sprite.new
  74.     spr.z = 100
  75.     spr.bitmap = Bitmap.new(@width,@height)
  76.     spr.ox=(area[0]+area[2])/2
  77.     spr.oy=(area[1]+area[3])/2
  78.     spr.x=(area[0]+area[2])/2
  79.     spr.y=(area[1]+area[3])/2
  80.     @shards[1] = spr
  81.     @shards[1].bitmap.blt(area[0], area[1], @picture, Rect.new(*area))
  82. #--------------------------------------------------------------------------   
  83.     area1 = [300,100,300,200]
  84.     spr1 = Sprite.new
  85.     spr1.z = 100
  86.     spr1.bitmap = Bitmap.new(@width,@height)
  87.     spr1.ox=(area[0]+area[2])/2
  88.     spr1.oy=(area[1]+area[3])/2
  89.     spr1.x=(area[0]+area[2])/2
  90.     spr1.y=(area[1]+area[3])/2
  91.     @shards[2] = spr1
  92.     @shards[2].bitmap.blt(area1[0], area1[1], @picture, Rect.new(*area1))
  93.   end
  94. end
  95. #============================================================
  96. # 本脚本由九夜神尊制作
  97. # 欢迎任意转载修改,但请保留作者名。
  98. #===========================================================
复制代码

Lv1.梦旅人

梦石
0
星屑
50
在线时间
616 小时
注册时间
2010-10-29
帖子
463
发表于 2012-12-6 05:56:47 | 显示全部楼层
貌似是这样的,很多调用精灵类的脚本在配置不怎么好的电脑上都会出现内存问题。只能删除这个脚本了。。。。我也不知道如何解决。。。。
我命令你给我点下面的东西!

LBQ Works
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-29 12:45

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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