Project1

标题: 请问,如何做到刷新很多图片。但又不会让程序自动关闭? [打印本页]

作者: ad1234a    时间: 2011-7-6 19:06
标题: 请问,如何做到刷新很多图片。但又不会让程序自动关闭?
每次内存占用一到430多M就自动关闭的。我感觉这个问题是因为图片刷新太多引起的:




标题画面(有同样问题的是主菜单)的脚本(要考虑到鼠标支持的):
  1. #==============================================================================
  2. # ■ Scene_Title
  3. #------------------------------------------------------------------------------
  4. #  处理标题画面的类。
  5. #==============================================================================

  6. class Scene_Title
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     menu_index : 命令光标的初期位置
  10.   #--------------------------------------------------------------------------
  11.   def initialize(title_index = 0)
  12.     @title_index = title_index
  13.   end
  14.   #--------------------------------------------------------------------------
  15.   # ● 住处理
  16.   #--------------------------------------------------------------------------
  17.   def main
  18.     # 战斗测试的情况下
  19.     if $BTEST
  20.       battle_test
  21.       return
  22.     end
  23.     # 载入数据库
  24.    # file = File.open("Data/lang.rxdata", "rb")
  25.    # $game_System_variables     = Marshal.load(file)
  26.    # file.close
  27.    
  28.     $data_actors        = load_data("Data/Actors.rxdata")
  29.     $data_classes       = load_data("Data/Classes.rxdata")
  30.     $data_skills        = load_data("Data/Skills.rxdata")
  31.     $data_items         = load_data("Data/Items.rxdata")
  32.     $data_weapons       = load_data("Data/Weapons.rxdata")
  33.     $data_armors        = load_data("Data/Armors.rxdata")
  34.     $data_enemies       = load_data("Data/Enemies.rxdata")
  35.     $data_troops        = load_data("Data/Troops.rxdata")
  36.     $data_states        = load_data("Data/States.rxdata")
  37.     $data_animations    = load_data("Data/Animations.rxdata")
  38.     $data_tilesets      = load_data("Data/Tilesets.rxdata")
  39.     $data_common_events = load_data("Data/CommonEvents.rxdata")
  40.     $data_system        = load_data("Data/System.rxdata")
  41.     $game_System_variables = load_data("Data/lang.rxdata")
  42.    
  43.     # 生成系统对像
  44.     $game_system = Game_System.new
  45.     # 生成标题图形
  46.     @sprite = Sprite.new
  47.     @sprite.bitmap = RPG::Cache.title($data_system.title_name)
  48.    # @command = Sprite.new
  49.    # @command.bitmap = Bitmap.new("Graphics/Pictures/titles/title_1")
  50.     #@command.x = 370
  51.     #@command.y = 230
  52.    
  53.     @Title_command_1 = Sprite.new
  54.     @Title_command_1.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-2")
  55.     @Title_command_1.x = 510
  56.     @Title_command_1.y = 270
  57.    
  58.     @Title_command_2 = Sprite.new
  59.     @Title_command_2.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-3")
  60.     @Title_command_2.x = 510
  61.     @Title_command_2.y = 320
  62.    
  63.     @Title_command_3 = Sprite.new
  64.     @Title_command_3.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-4")
  65.     @Title_command_3.x = 510
  66.     @Title_command_3.y = 370
  67.    
  68.     @Title_command_4 = Sprite.new
  69.     @Title_command_4.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-5")
  70.     @Title_command_4.x = 510
  71.     @Title_command_4.y = 420
  72.    
  73.     @Title_command_5 = Sprite.new
  74.     @Title_command_5.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-6")
  75.     @Title_command_5.x = 510
  76.     @Title_command_5.y = 470
  77.    
  78.     @system_variable_value = 1
  79.    
  80.     # 生成命令窗口
  81.    
  82.   # s1 = "故事模式"
  83.    #s2 = "遊戲設定"
  84.   # s3 = "附加內容"
  85.   # s4 = "退出遊戲"
  86.   
  87.    s1 = ""
  88.    s2 = ""
  89.    s3 = ""
  90.    s4 = ""
  91.    s5 = ""
  92.    
  93.    settings1 = "繁體中文"
  94.    settings2 = "简体中文"
  95.    
  96. # if @system_variable_value == 1
  97.   #  @command.bitmap = Bitmap.new("Graphics/Pictures/titles/title_1")
  98. # end
  99.   
  100.   
  101.     @Title_system_window = Window_Command_Title.new(122, [settings1, settings2])
  102.     @Title_system_window.back_opacity = 160
  103.     @Title_system_window.opacity = 0
  104.     @Title_system_window.x = 500 - @Title_system_window.width / 2
  105.     @Title_system_window.y = 258
  106.     @Title_system_window.visible = false
  107.     @Title_system_window.active = false
  108.    
  109.     @command_window = Window_Command_Title.new(192, [s1, s2, s3 ,s4 , s5])
  110.     @command_window.back_opacity = 160
  111.     @command_window.opacity = 0
  112.     @command_window.x = 620 - @command_window.width / 2
  113.     @command_window.y = 258
  114.     @command_window.windowskin = RPG::Cache.windowskin("")
  115.     @command_window.index = @title_index

  116.     # 演奏标题 BGM
  117.     $game_system.bgm_play($data_system.title_bgm)
  118.    
  119.     # 停止演奏 ME、BGS
  120.     Audio.me_stop
  121.     Audio.bgs_stop
  122.     # 执行过渡
  123.     Graphics.transition
  124.     # 主循环
  125.     loop do
  126.       # 刷新游戏画面
  127.       Graphics.update
  128.       # 刷新输入信息
  129.       Input.update
  130.       # 刷新画面
  131.       update
  132.       # 如果画面被切换就中断循环
  133.       if $scene != self
  134.         break
  135.       end
  136.     end
  137.     # 装备过渡
  138.     Graphics.freeze
  139.     # 释放命令窗口
  140.     @command_window.dispose
  141.     # 释放标题图形
  142.     @sprite.bitmap.dispose
  143.     @sprite.dispose
  144.     #@command.dispose
  145.     @Title_command_1.dispose
  146.     @Title_command_2.dispose
  147.     @Title_command_3.dispose
  148.     @Title_command_4.dispose
  149.     @Title_command_5.dispose
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # ● 刷新画面
  153.   #--------------------------------------------------------------------------
  154.   def update
  155.     # 刷新命令窗口
  156.     @command_window.update
  157.     if @Title_system_window.active
  158.     @Title_system_window.update
  159.   end
  160.   
  161.       case @command_window.index
  162.       when 0  # 開始遊戲
  163.       @wait_count = 20
  164.     @Title_command_1.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-7")
  165.     @Title_command_2.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-3")
  166.     @Title_command_3.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-4")
  167.     @Title_command_4.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-5")
  168.     @Title_command_5.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-6")
  169.     #@command.bitmap = Bitmap.new("Graphics/Pictures/titles/title_1")
  170.       when 1  # 讀取遊戲
  171.       @wait_count = 20
  172.   #  @command.bitmap = Bitmap.new("Graphics/Pictures/titles/title_2")
  173.     @Title_command_1.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-2")
  174.     @Title_command_2.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-8")
  175.     @Title_command_3.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-4")
  176.     @Title_command_4.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-5")
  177.     @Title_command_5.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-6")
  178.       when 2  # 遊戲設定
  179.       @wait_count = 20
  180.   # @command.bitmap = Bitmap.new("Graphics/Pictures/titles/title_3")
  181.     @Title_command_1.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-2")
  182.     @Title_command_2.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-3")
  183.     @Title_command_3.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-9")
  184.     @Title_command_4.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-5")
  185.     @Title_command_5.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-6")
  186.     when 3  # 離開遊戲
  187.       @wait_count = 20
  188.     @Title_command_1.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-2")
  189.     @Title_command_2.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-3")
  190.     @Title_command_3.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-4")
  191.     @Title_command_4.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-10")
  192.     @Title_command_5.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-6")
  193.     when 4  #
  194.       @wait_count = 20
  195.     @Title_command_1.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-2")
  196.     @Title_command_2.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-3")
  197.     @Title_command_3.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-4")
  198.     @Title_command_4.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-5")
  199.     @Title_command_5.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-11")
  200.    
  201.   end
  202.   
  203.   
  204.    if @Title_system_window.active
  205.     if Input.trigger?(Input::B)
  206.     @command_window.active = true
  207.     @command_window.visible = true
  208.     @Title_system_window.active = false
  209.     @Title_system_window.visible = false
  210.   end
  211.   end
  212.       
  213.     # 按下 C 键的情况下
  214.     if Input.trigger?(Input::C)
  215.       case @Title_system_window.index
  216.       when 0
  217.         system_cht
  218.       when 1
  219.         system_chs
  220.       end
  221.       
  222.       # 命令窗口的光标位置的分支
  223.       case @command_window.index
  224.       when 0  # 新游戏
  225.         command_new_game
  226.       when 1  # 继续
  227.         command_continue
  228.       when 2  # 系统设定
  229.         command_systemsettings
  230.       when 3  # 退出
  231.         command_shutdown
  232.       when 4 #
  233.         command_movie
  234.       end
  235.     end
  236.   end
  237.   
  238.   #-----------------------------------
  239.   
  240.    
  241.   #--------------------------------------------------------------------------
  242.   # ● 命令 : 新游戏
  243.   #--------------------------------------------------------------------------
  244.   def command_new_game
  245.     # 演奏确定 SE
  246.     $game_system.se_play($data_system.decision_se)
  247.     # 停止 BGM
  248.     Audio.bgm_stop
  249.     # 重置测量游戏时间用的画面计数器
  250.     Graphics.frame_count = 0
  251.     # 生成各种游戏对像
  252.     $game_temp          = Game_Temp.new
  253.     $game_system        = Game_System.new
  254.     $game_switches      = Game_Switches.new
  255.     $game_variables     = Game_Variables.new
  256.     $game_self_switches = Game_SelfSwitches.new
  257.     $game_screen        = Game_Screen.new
  258.     $game_actors        = Game_Actors.new
  259.     $game_party         = Game_Party.new
  260.     $game_troop         = Game_Troop.new
  261.     $game_map           = Game_Map.new
  262.     $game_player        = Game_Player.new
  263.     #$game_System_variables = load_data("Data/lang.rxdata")
  264.    
  265.     # 设置初期同伴位置
  266.     $game_party.setup_starting_members
  267.     # 设置初期位置的地图
  268.     $game_map.setup($data_system.start_map_id)
  269.     # 主角向初期位置移动
  270.     $game_player.moveto($data_system.start_x, $data_system.start_y)
  271.     # 刷新主角
  272.     $game_player.refresh
  273.     # 执行地图设置的 BGM 与 BGS 的自动切换
  274.     $game_map.autoplay
  275.     # 刷新地图 (执行并行事件)
  276.     $game_map.update
  277.     # 切换地图画面
  278.     $scene = Scene_Map.new
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ● 命令 : 继续
  282.   #--------------------------------------------------------------------------
  283.   def command_continue
  284.     # 继续无效的情况下
  285.    # unless @continue_enabled
  286.       # 演奏无效 SE
  287.     #  $game_system.se_play($data_system.buzzer_se)
  288.     #  return
  289.    # end
  290.     # 演奏确定 SE
  291.     $game_system.se_play($data_system.decision_se)
  292.     # 切换到读档画面
  293.     $scene = Scene_Load.new
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # ● 命令 : 退出
  297.   #--------------------------------------------------------------------------
  298.   def command_shutdown
  299.     # 演奏确定 SE
  300.     $game_system.se_play($data_system.decision_se)
  301.     # BGM、BGS、ME 的淡入淡出
  302.     Audio.bgm_fade(800)
  303.     Audio.bgs_fade(800)
  304.     Audio.me_fade(800)
  305.     # 退出
  306.     $scene = nil
  307.   end
  308.   #--------------------------------------------------------------------------
  309.   # ● 命令 : 系統設定
  310.   #--------------------------------------------------------------------------
  311.   def  command_systemsettings
  312.     # 演奏确定 SE
  313.     $game_system.se_play($data_system.decision_se)
  314.     #$scene = Scene_SystemSettings.new
  315.     @Title_system_window.active =  true
  316.     @Title_system_window.visible = true
  317.     @command_window.active = false
  318.     @command_window.visible = false
  319.   end
  320.   
  321.   #--------------------------------------------------------------------------
  322.   # ● 命令 : 過場動畫
  323.   #--------------------------------------------------------------------------
  324.   def command_movie
  325.     # 继续无效的情况下
  326.    # unless @continue_enabled
  327.       # 演奏无效 SE
  328.       $game_system.se_play($data_system.buzzer_se)
  329.     #  return
  330.     end
  331.   
  332.   #--------------------------------------------------------------------------
  333.   # 以下为與語言設定有關部分,請別亂改動
  334.   #--------------------------------------------------------------------------
  335.   
  336.   def system_cht
  337.     $game_system.se_play($data_system.decision_se)
  338.     #此為繁體版程式所用
  339.    # @system_variable_value = 1
  340.     #$data_system        = load_data("Data/System_1.rxdata")
  341.   #  file=File.open("Data/lang.rxdata", "wb")
  342.   #  Marshal.dump($game_System_variables, file)
  343.    # file.close
  344.    
  345.     @command_window.active = true
  346.     @command_window.visible = true
  347.     @Title_system_window.active =  false
  348.     @Title_system_window.visible = false
  349.   end
  350.   
  351.   def system_chs
  352.     $game_system.se_play($data_system.decision_se)
  353.    
  354.     #此为簡體版程式所用
  355.   #  @system_variable_value = 2
  356.     #$data_system        = load_data("Data/System_1.rxdata")
  357.   #  file=File.open("Data/lang.rxdata", "wb")
  358.    # Marshal.dump($game_System_variables, file)
  359.    # file.close
  360.    
  361.     @command_window.active = true
  362.     @command_window.visible = true
  363.     @Title_system_window.active =  false
  364.     @Title_system_window.visible = false
  365.   end
  366.   
  367.   #--------------------------------------------------------------------------
  368.   # ● 战斗测试
  369.   #--------------------------------------------------------------------------
  370.   def battle_test
  371.     # 载入数据库 (战斗测试用)
  372.     $data_actors        = load_data("Data/Actors.rxdata")
  373.     $data_classes       = load_data("Data/Classes.rxdata")
  374.     $data_skills        = load_data("Data/Skills.rxdata")
  375.     $data_items         = load_data("Data/Items.rxdata")
  376.     $data_weapons       = load_data("Data/Weapons.rxdata")
  377.     $data_armors        = load_data("Data/Armors.rxdata")
  378.     $data_enemies       = load_data("Data/Enemies.rxdata")
  379.     $data_troops        = load_data("Data/Troops.rxdata")
  380.     $data_states        = load_data("Data/States.rxdata")
  381.     $data_animations    = load_data("Data/Animations.rxdata")
  382.     $data_tilesets      = load_data("Data/Tilesets.rxdata")
  383.     $data_common_events = load_data("Data/CommonEvents.rxdata")
  384.     $data_system        = load_data("Data/System.rxdata")
  385.     # 重置测量游戏时间用的画面计数器
  386.     Graphics.frame_count = 0
  387.     # 生成各种游戏对像
  388.     $game_temp          = Game_Temp.new
  389.     $game_system        = Game_System.new
  390.     $game_switches      = Game_Switches.new
  391.     $game_variables     = Game_Variables.new
  392.     $game_self_switches = Game_SelfSwitches.new
  393.     $game_screen        = Game_Screen.new
  394.     $game_actors        = Game_Actors.new
  395.     $game_party         = Game_Party.new
  396.     $game_troop         = Game_Troop.new
  397.     $game_map           = Game_Map.new
  398.     $game_player        = Game_Player.new
  399.     # 设置战斗测试用同伴
  400.     $game_party.setup_battle_test_members
  401.     # 设置队伍 ID、可以逃走标志、战斗背景
  402.     $game_temp.battle_troop_id = $data_system.test_troop_id
  403.     $game_temp.battle_can_escape = true
  404.     $game_map.battleback_name = $data_system.battleback_name
  405.     # 演奏战斗开始 BGM
  406.     $game_system.se_play($data_system.battle_start_se)
  407.     # 演奏战斗 BGM
  408.     $game_system.bgm_play($game_system.battle_bgm)
  409.     # 切换到战斗画面
  410.     $scene = Scene_Battle.new
  411.   end
  412. end
复制代码
另外,这个是主菜单的刷新部分:
  1.   if @menu_window.active
  2.     case @menu_window.index
  3.     when 0
  4.     @command2_1.bitmap = Bitmap.new("Graphics/Pictures/物品·一")
  5.     @command2_2.bitmap = Bitmap.new("Graphics/Pictures/装备·平常")
  6.     @command2_3.bitmap = Bitmap.new("Graphics/Pictures/奇术·一")
  7.     @command2_4.bitmap = Bitmap.new("Graphics/Pictures/天书·平常")
  8.     @command2_5.bitmap = Bitmap.new("Graphics/Pictures/记载·平常")
  9.     @command2_6.bitmap = Bitmap.new("Graphics/Pictures/系统·平常")
  10.     when 1
  11.     @command2_1.bitmap = Bitmap.new("Graphics/Pictures/物品·平常")
  12.     @command2_2.bitmap = Bitmap.new("Graphics/Pictures/装备·一")
  13.     @command2_3.bitmap = Bitmap.new("Graphics/Pictures/奇术·一")
  14.     @command2_4.bitmap = Bitmap.new("Graphics/Pictures/天书·平常")
  15.     @command2_5.bitmap = Bitmap.new("Graphics/Pictures/记载·平常")
  16.     @command2_6.bitmap = Bitmap.new("Graphics/Pictures/系统·平常")
  17.     when 2
  18.     @command2_1.bitmap = Bitmap.new("Graphics/Pictures/物品·平常")
  19.     @command2_2.bitmap = Bitmap.new("Graphics/Pictures/装备·平常")
  20.     @command2_3.bitmap = Bitmap.new("Graphics/Pictures/奇术·二")
  21.     @command2_4.bitmap = Bitmap.new("Graphics/Pictures/天书·平常")
  22.     @command2_5.bitmap = Bitmap.new("Graphics/Pictures/记载·平常")
  23.     @command2_6.bitmap = Bitmap.new("Graphics/Pictures/系统·平常")
  24.     when 3
  25.     @command2_1.bitmap = Bitmap.new("Graphics/Pictures/物品·平常")
  26.     @command2_2.bitmap = Bitmap.new("Graphics/Pictures/装备·平常")
  27.     @command2_3.bitmap = Bitmap.new("Graphics/Pictures/奇术·一")
  28.     @command2_4.bitmap = Bitmap.new("Graphics/Pictures/天书·一")
  29.     @command2_5.bitmap = Bitmap.new("Graphics/Pictures/记载·平常")
  30.     @command2_6.bitmap = Bitmap.new("Graphics/Pictures/系统·平常")
  31.     when 4
  32.     @command2_1.bitmap = Bitmap.new("Graphics/Pictures/物品·平常")
  33.     @command2_2.bitmap = Bitmap.new("Graphics/Pictures/装备·平常")
  34.     @command2_3.bitmap = Bitmap.new("Graphics/Pictures/奇术·一")
  35.     @command2_4.bitmap = Bitmap.new("Graphics/Pictures/天书·平常")
  36.     @command2_5.bitmap = Bitmap.new("Graphics/Pictures/记载·一")
  37.     @command2_6.bitmap = Bitmap.new("Graphics/Pictures/系统·平常")
  38.     when 5
  39.     @command2_1.bitmap = Bitmap.new("Graphics/Pictures/物品·平常")
  40.     @command2_2.bitmap = Bitmap.new("Graphics/Pictures/装备·平常")
  41.     @command2_3.bitmap = Bitmap.new("Graphics/Pictures/奇术·一")
  42.     @command2_4.bitmap = Bitmap.new("Graphics/Pictures/天书·平常")
  43.     @command2_5.bitmap = Bitmap.new("Graphics/Pictures/记载·平常")
  44.     @command2_6.bitmap = Bitmap.new("Graphics/Pictures/系统·一")
  45.   end
  46. end
复制代码
dsu_plus_rewardpost_czw
作者: 忧雪の伤    时间: 2011-7-6 19:16
  1. #==============================================================================
  2. # ■  Hangup 异常根除
  3. #    Hangup Exception Eradication
  4. #----------------------------------------------------------------------------
  5. #
  6. #    Hangup 异常是 RMXP 底层引擎内置的一个异常类,游戏进程会在 Graphics.update
  7. #    没有调用超过 10 秒时抛出这个异常。这个脚本使用了 Windows API 暴力地解除
  8. #    了这个限制。
  9. #    使用方法:Hangup 异常根除脚本必须插入到脚本编辑器的最顶端,所有脚本之前,无
  10. #    例外。
  11. #
  12. #----------------------------------------------------------------------------
  13. #
  14. #    更新作者: 紫苏
  15. #    许可协议: FSL -MEE
  16. #    项目版本: 1.2.0827
  17. #    引用网址:
  18. #    http://rpg.blue/forum.php?mod=viewthread&tid=134316
  19. #    http://szsu.wordpress.com/2010/08/09/hangup_eradication
  20. #
  21. #----------------------------------------------------------------------------
  22. #
  23. #    - 1.2.0827 By 紫苏
  24. #      * 更改了配置模块名
  25. #      * 更改了 FSL 注释信息
  26. #
  27. #    - 1.2.0805 By 紫苏
  28. #      * 脚本开始遵循 FSL
  29. #      * 全局范围内改变了脚本结构
  30. #
  31. #    - 1.1.1101 By 紫苏
  32. #      * 修正了脚本在 Windows XP 平台下失效的问题
  33. #
  34. #    - 1.0.0927 By 紫苏
  35. #      * 初始版本完成
  36. #
  37. #==============================================================================

  38. $__jmp_here.call if $__jmp_here

  39. #----------------------------------------------------------------------------
  40. # ● 登记 FSL。
  41. #----------------------------------------------------------------------------
  42. $fscript = {} if !$fscript
  43. $fscript['HangupEradication'] = '1.2.0827'

  44. #==============================================================================
  45. # ■ FSL
  46. #------------------------------------------------------------------------------
  47. #  自由RGSS脚本通用公开协议的功能模块。
  48. #==============================================================================

  49. module FSL
  50.   module HangupEradication
  51.     #------------------------------------------------------------------------
  52.     # ● 定义需要的 Windows API。
  53.     #------------------------------------------------------------------------
  54.     OpenThread = Win32API.new('kernel32', 'OpenThread', 'LIL', 'L')
  55.     CloseHandle = Win32API.new('kernel32', 'CloseHandle', 'L', 'I')
  56.     Thread32Next = Win32API.new('kernel32', 'Thread32Next', 'LP', 'I')
  57.     ResumeThread = Win32API.new('kernel32', 'ResumeThread', 'L', 'L')
  58.     SuspendThread = Win32API.new('kernel32', 'SuspendThread', 'L', 'L')
  59.     Thread32First = Win32API.new('kernel32', 'Thread32First', 'LP', 'I')
  60.     GetCurrentProcessId = Win32API.new('kernel32', 'GetCurrentProcessId', 'V', 'L')
  61.     CreateToolhelp32Snapshot = Win32API.new('kernel32', 'CreateToolhelp32Snapshot', 'LL', 'L')
  62.   end
  63. end

  64. #==============================================================================
  65. # ■ HangupEradication
  66. #------------------------------------------------------------------------------
  67. #  处理根除 Hangup 异常的类。
  68. #==============================================================================

  69. class HangupEradication
  70.   include FSL::HangupEradication
  71.   #--------------------------------------------------------------------------
  72.   # ● 初始化对像。
  73.   #--------------------------------------------------------------------------
  74.   def initialize
  75.     @hSnapShot = CreateToolhelp32Snapshot.call(4, 0)
  76.     @hLastThread = OpenThread.call(2, 0, self.getLastThreadId)
  77.     #@hLastThread = OpenThread.call(2097151, 0, threadID)
  78.     ObjectSpace.define_finalizer(self, self.method(:finalize))
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ● 获取当前进程创建的最后一个线程的标识。
  82.   #--------------------------------------------------------------------------
  83.   def getLastThreadId
  84.     threadEntry = [28, 0, 0, 0, 0, 0, 0].pack("L*")
  85.     threadId = 0                                          # 线程标识
  86.     found = Thread32First.call(@hSnapShot, threadEntry)   # 准备枚举线程
  87.     while found != 0
  88.       arrThreadEntry = threadEntry.unpack("L*")           # 线程数据解包
  89.       if arrThreadEntry[3] == GetCurrentProcessId.call    # 匹配进程标识
  90.         threadId = arrThreadEntry[2]                      # 记录线程标识
  91.       end
  92.       found = Thread32Next.call(@hSnapShot, threadEntry)  # 下一个线程
  93.     end
  94.     return threadId
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ● 根除 Hangup 异常。
  98.   #     2       : “暂停和恢复线程访问权限”代码;
  99.   #     2097151 : “所有可能的访问权限”代码(Windows XP 平台下无效)。
  100.   #--------------------------------------------------------------------------
  101.   def eradicate
  102.     SuspendThread.call(@hLastThread)
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # ● 恢复 Hangup 异常。
  106.   #--------------------------------------------------------------------------
  107.   def resume
  108.     while ResumeThread.call(@hLastThread) > 1; end        # 恢复最后一个线程
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● 最终化对像。
  112.   #--------------------------------------------------------------------------
  113.   def finalize
  114.     CloseHandle.call(@hSnapShot)
  115.     CloseHandle.call(@hLastThread)
  116.   end
  117. end

  118. hangupEradication = HangupEradication.new
  119. hangupEradication.eradicate

  120. callcc { |$__jmp_here| }                                  # F12 后的跳转标记

  121. #==============================================================================
  122. # ■ 游戏主过程
  123. #------------------------------------------------------------------------------
  124. #  游戏脚本的解释从这个外壳开始。
  125. #==============================================================================

  126. for subscript in 1...$RGSS_SCRIPTS.size
  127.   begin
  128.     eval(Zlib::Inflate.inflate($RGSS_SCRIPTS[subscript][2]))
  129.   rescue Exception => ex
  130.     # 异常发生并抛出给解释器时恢复线程。
  131.     hangupEradication.resume unless defined?(Reset) and ex.class == Reset
  132.     raise ex
  133.   end
  134. end

  135. hangupEradication.resume
  136. exit
复制代码

作者: plummy    时间: 2011-7-6 19:22
建议去看看柳柳的《公共事件制作菜单》,别用脚本了
作者: Wind2010    时间: 2011-7-6 19:23
本帖最后由 Wind2010 于 2011-7-6 19:38 编辑

感觉应该不会到卡死的程度- -倒是觉得LZ频繁刷新了


嗯,试试这样会不会好点:
  1. class Scene_Title
  2.   def update
  3.     if @wait_count > 1
  4.       @wait_count -= 1
  5.       return
  6.     end
  7.     # 刷新命令窗口
  8.     @command_window.update
  9.     if @Title_system_window.active
  10.       @Title_system_window.update
  11.     end
  12.     if @old_index != @command_window.index
  13.       @old_index = @command_window.index
  14.       case @command_window.index
  15.       when 0  # 開始遊戲
  16.         @wait_count = 20
  17.         @Title_command_1.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-7")
  18.         @Title_command_2.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-3")
  19.         @Title_command_3.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-4")
  20.         @Title_command_4.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-5")
  21.         @Title_command_5.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-6")
  22.       when 1  # 讀取遊戲
  23.         @wait_count = 20
  24.      #  @command.bitmap = Bitmap.new("Graphics/Pictures/titles/title_2")
  25.         @Title_command_1.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-2")
  26.         @Title_command_2.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-8")
  27.         @Title_command_3.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-4")
  28.         @Title_command_4.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-5")
  29.         @Title_command_5.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-6")
  30.       when 2  # 遊戲設定
  31.         @wait_count = 20
  32.       # @command.bitmap = Bitmap.new("Graphics/Pictures/titles/title_3")
  33.         @Title_command_1.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-2")
  34.         @Title_command_2.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-3")
  35.         @Title_command_3.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-9")
  36.         @Title_command_4.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-5")
  37.         @Title_command_5.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-6")
  38.       when 3  # 離開遊戲
  39.         @wait_count = 20
  40.         @Title_command_1.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-2")
  41.         @Title_command_2.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-3")
  42.         @Title_command_3.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-4")
  43.         @Title_command_4.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-10")
  44.         @Title_command_5.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-6")
  45.       when 4  #
  46.         @wait_count = 20
  47.         @Title_command_1.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-2")
  48.         @Title_command_2.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-3")
  49.         @Title_command_3.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-4")
  50.         @Title_command_4.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-5")
  51.         @Title_command_5.bitmap = Bitmap.new("Graphics/Pictures/title_command/63-11")
  52.       end
  53.     end
  54.     if @Title_system_window.active
  55.       if Input.trigger?(Input::B)
  56.         @command_window.active = true
  57.         @command_window.visible = true
  58.         @Title_system_window.active = false
  59.         @Title_system_window.visible = false
  60.         return
  61.       end
  62.     end
  63.     # 按下 C 键的情况下
  64.     if Input.trigger?(Input::C)
  65.       case @Title_system_window.index
  66.       when 0
  67.         system_cht
  68.         return
  69.       when 1
  70.         system_chs
  71.         return
  72.       end
  73.       # 命令窗口的光标位置的分支
  74.       case @command_window.index
  75.       when 0  # 新游戏
  76.         command_new_game
  77.       when 1  # 继续
  78.         command_continue
  79.       when 2  # 系统设定
  80.         command_systemsettings
  81.       when 3  # 退出
  82.         command_shutdown
  83.       when 4 #
  84.         command_movie
  85.       end
  86.     end
  87.   end
  88. end
复制代码
直接当外来脚本插入就行了,或者删掉最上面一行和最下面一行然后替换掉update
作者: 忧雪の伤    时间: 2011-7-6 19:28
本帖最后由 忧雪の伤 于 2011-7-6 19:30 编辑
Wind2010 发表于 2011-7-6 19:23
感觉应该不会到卡死的程度- -倒是觉得LZ频繁刷新了


一直构建Bitmap这种极其消耗效率的实例。不卡也奇怪……
所以……Bitmap#dispose吧。
作者: Wind2010    时间: 2011-7-6 19:37
于是乎被隔开一楼就不连帖了XD


这个是主菜单的修改,就是你发出来的第二个脚本
  1.   if @menu_window.active
  2.     if @old_index != @menu_index
  3.       @old_index = @menu_index
  4.       case @menu_window.index
  5.       when 0
  6.         @command2_1.bitmap = Bitmap.new("Graphics/Pictures/物品·一")
  7.         @command2_2.bitmap = Bitmap.new("Graphics/Pictures/装备·平常")
  8.         @command2_3.bitmap = Bitmap.new("Graphics/Pictures/奇术·一")
  9.         @command2_4.bitmap = Bitmap.new("Graphics/Pictures/天书·平常")
  10.         @command2_5.bitmap = Bitmap.new("Graphics/Pictures/记载·平常")
  11.         @command2_6.bitmap = Bitmap.new("Graphics/Pictures/系统·平常")
  12.       when 1
  13.         @command2_1.bitmap = Bitmap.new("Graphics/Pictures/物品·平常")
  14.         @command2_2.bitmap = Bitmap.new("Graphics/Pictures/装备·一")
  15.         @command2_3.bitmap = Bitmap.new("Graphics/Pictures/奇术·一")
  16.         @command2_4.bitmap = Bitmap.new("Graphics/Pictures/天书·平常")
  17.         @command2_5.bitmap = Bitmap.new("Graphics/Pictures/记载·平常")
  18.         @command2_6.bitmap = Bitmap.new("Graphics/Pictures/系统·平常")
  19.       when 2
  20.         @command2_1.bitmap = Bitmap.new("Graphics/Pictures/物品·平常")
  21.         @command2_2.bitmap = Bitmap.new("Graphics/Pictures/装备·平常")
  22.         @command2_3.bitmap = Bitmap.new("Graphics/Pictures/奇术·二")
  23.         @command2_4.bitmap = Bitmap.new("Graphics/Pictures/天书·平常")
  24.         @command2_5.bitmap = Bitmap.new("Graphics/Pictures/记载·平常")
  25.         @command2_6.bitmap = Bitmap.new("Graphics/Pictures/系统·平常")
  26.       when 3
  27.         @command2_1.bitmap = Bitmap.new("Graphics/Pictures/物品·平常")
  28.         @command2_2.bitmap = Bitmap.new("Graphics/Pictures/装备·平常")
  29.         @command2_3.bitmap = Bitmap.new("Graphics/Pictures/奇术·一")
  30.         @command2_4.bitmap = Bitmap.new("Graphics/Pictures/天书·一")
  31.         @command2_5.bitmap = Bitmap.new("Graphics/Pictures/记载·平常")
  32.         @command2_6.bitmap = Bitmap.new("Graphics/Pictures/系统·平常")
  33.       when 4
  34.         @command2_1.bitmap = Bitmap.new("Graphics/Pictures/物品·平常")
  35.         @command2_2.bitmap = Bitmap.new("Graphics/Pictures/装备·平常")
  36.         @command2_3.bitmap = Bitmap.new("Graphics/Pictures/奇术·一")
  37.         @command2_4.bitmap = Bitmap.new("Graphics/Pictures/天书·平常")
  38.         @command2_5.bitmap = Bitmap.new("Graphics/Pictures/记载·一")
  39.         @command2_6.bitmap = Bitmap.new("Graphics/Pictures/系统·平常")
  40.       when 5
  41.         @command2_1.bitmap = Bitmap.new("Graphics/Pictures/物品·平常")
  42.         @command2_2.bitmap = Bitmap.new("Graphics/Pictures/装备·平常")
  43.         @command2_3.bitmap = Bitmap.new("Graphics/Pictures/奇术·一")
  44.         @command2_4.bitmap = Bitmap.new("Graphics/Pictures/天书·平常")
  45.         @command2_5.bitmap = Bitmap.new("Graphics/Pictures/记载·平常")
  46.         @command2_6.bitmap = Bitmap.new("Graphics/Pictures/系统·一")
  47.       end
  48.     end
  49.   end
复制代码

作者: R-零    时间: 2011-7-10 15:29
换个方法吧,先修改Scene_Title 跳过标题画面
直接进入初期地图
用事件制作标题






欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1