Project1

标题: 求解!自己编写的Scene黑屏! [打印本页]

作者: tamashii    时间: 2011-7-7 18:01
标题: 求解!自己编写的Scene黑屏!
  1. # Scene : Splash
  2. # Usage : To show a logo in game.
  3. # Author : Tamashii
  4. # Copyright (c) 2011, Tamashii / DLM Studio.
  5. class Scene_Splash
  6.   # Main processing
  7.   def main
  8.     if $BTEST
  9.       battle_test
  10.       return
  11.     end
  12.     @bg = Sprite.new
  13.     @bg.bitmap = Bitmap.new(640, 480)
  14.     @bg.bitmap.fill_rect(0, 0, 640, 480, Color.new(255, 255, 255))
  15.     @bg.bitmap.font.color = Color.new(0, 0, 0)
  16.     @bg.bitmap.font.name = ["Arial"]
  17.     @bg.bitmap.draw_text(0, 32, 640, 32, "It's a tale told by :", 1)
  18.     @bg.opacity = 0
  19.     @sprite = Sprite.new
  20.     @sprite.bitmap = Bitmap.new("Graphics/Pictures/logo")
  21.     @sprite.opacity = 0
  22.     @fadeout = false
  23.     @frame_count = 0
  24.     loop do
  25.       Graphics.update
  26.       Input.update
  27.       update
  28.       if $scene != self
  29.         break
  30.       end
  31.     end
  32.     @sprite.bitmap.dispose
  33.     @sprite.dispose
  34.     @bg.bitmap.dispose
  35.     @bg.dispose
  36.   end
  37.   # Update frame
  38.   def update
  39.     if Input.trigger?(Input::A) or Input.trigger?(Input::B) or Input.trigger?(Input::C)
  40.       $scene = Scene_Title.new
  41.       return
  42.     end
  43.     unless @fadeout
  44.       if @bg.opacity < 255
  45.         @bg.opacity += 10
  46.         return
  47.       end
  48.       if @sprite.opacity < 255
  49.         @sprite.opacity += 10
  50.         return
  51.       end
  52.       @frame_count += 1
  53.       if (@frame_count = 40)
  54.         @fadeout = true
  55.       end
  56.       return
  57.     end
  58.     if @sprite.opacity > 0
  59.       @sprite.opacity -= 10
  60.       return
  61.     end
  62.     if @bg.opacity > 0
  63.       @bg.opacity -= 10
  64.       return
  65.     end
  66.     $scene = Scene_Title.new
  67.   end
  68.   # Battle test
  69.   def battle_test
  70.     # Loading database for battle test
  71.     $data_actors        = load_data("Data/BT_Actors.rxdata")
  72.     $data_classes       = load_data("Data/BT_Classes.rxdata")
  73.     $data_skills        = load_data("Data/BT_Skills.rxdata")
  74.     $data_items         = load_data("Data/BT_Items.rxdata")
  75.     $data_weapons       = load_data("Data/BT_Weapons.rxdata")
  76.     $data_armors        = load_data("Data/BT_Armors.rxdata")
  77.     $data_enemies       = load_data("Data/BT_Enemies.rxdata")
  78.     $data_troops        = load_data("Data/BT_Troops.rxdata")
  79.     $data_states        = load_data("Data/BT_States.rxdata")
  80.     $data_animations    = load_data("Data/BT_Animations.rxdata")
  81.     $data_tilesets      = load_data("Data/BT_Tilesets.rxdata")
  82.     $data_common_events = load_data("Data/BT_CommonEvents.rxdata")
  83.     $data_system        = load_data("Data/BT_System.rxdata")
  84.     # reset game timer counter
  85.     Graphics.frame_count = 0
  86.     # anylize game objects
  87.     $game_temp          = Game_Temp.new
  88.     $game_system        = Game_System.new
  89.     $game_switches      = Game_Switches.new
  90.     $game_variables     = Game_Variables.new
  91.     $game_self_switches = Game_SelfSwitches.new
  92.     $game_screen        = Game_Screen.new
  93.     $game_actors        = Game_Actors.new
  94.     $game_party         = Game_Party.new
  95.     $game_troop         = Game_Troop.new
  96.     $game_map           = Game_Map.new
  97.     $game_player        = Game_Player.new
  98.     # setup parties used to battle test
  99.     $game_party.setup_battle_test_members
  100.     # setup troop ID, can escape mark, battle background.
  101.     $game_temp.battle_troop_id = $data_system.test_troop_id
  102.     $game_temp.battle_can_escape = true
  103.     $game_map.battleback_name = $data_system.battleback_name
  104.     # play battle start SE
  105.     $game_system.se_play($data_system.battle_start_se)
  106.     # play battle BGM
  107.     $game_system.bgm_play($game_system.battle_bgm)
  108.     # move to battle scene
  109.     $scene = Scene_Battle.new
  110.   end
  111. end
复制代码
运行该Scene,发现一片漆黑。
求解 - -dsu_plus_rewardpost_czw
作者: cinderelmini    时间: 2011-7-7 18:07
首先 class Scene_Splash
后面加上 < Scene
然后试试~
作者: 忧雪の伤    时间: 2011-7-7 18:47
  1. # Scene : Splash
  2. # Usage : To show a logo in game.
  3. # Author : Tamashii
  4. # Copyright (c) 2011, Tamashii / DLM Studio.
  5. class Scene_Splash
  6.   # Main processing
  7.   def main
  8.     if $BTEST
  9.       battle_test
  10.       return
  11.     end
  12.     @bg = Sprite.new
  13.     @bg.bitmap = Bitmap.new(640, 480)
  14.     @bg.bitmap.fill_rect(0, 0, 640, 480, Color.new(255, 255, 255))
  15.     @bg.bitmap.font.color = Color.new(0, 0, 0)
  16.     @bg.bitmap.font.name = ["Arial"]
  17.     @bg.bitmap.draw_text(0, 32, 640, 32, "It's a tale told by :", 1)
  18.     @bg.opacity = 0
  19.     @sprite = Sprite.new
  20.     @sprite.bitmap = Bitmap.new("Graphics/Pictures/logo")
  21.     @sprite.opacity = 0
  22.     @fadeout = false
  23.     @frame_count = 0
  24.     Graphics.transition
  25.     loop do
  26.       Graphics.update
  27.       Input.update
  28.       update
  29.       if $scene != self
  30.         break
  31.       end
  32.     end
  33.     Graphics.freeze
  34.     @sprite.bitmap.dispose
  35.     @sprite.dispose
  36.     @bg.bitmap.dispose
  37.     @bg.dispose
  38.   end
  39.   # Update frame
  40.   def update
  41.     if Input.trigger?(Input::A) or Input.trigger?(Input::B) or Input.trigger?(Input::C)
  42.       $scene = Scene_Title.new
  43.       return
  44.     end
  45.     unless @fadeout
  46.       if @bg.opacity < 255
  47.         @bg.opacity += 10
  48.         return
  49.       end
  50.       if @sprite.opacity < 255
  51.         @sprite.opacity += 10
  52.         return
  53.       end
  54.       @frame_count += 1
  55.       if (@frame_count = 40)
  56.         @fadeout = true
  57.       end
  58.       return
  59.     end
  60.     if @sprite.opacity > 0
  61.       @sprite.opacity -= 10
  62.       return
  63.     end
  64.     if @bg.opacity > 0
  65.       @bg.opacity -= 10
  66.       return
  67.     end
  68.     $scene = Scene_Title.new
  69.   end
  70.   # Battle test
  71.   def battle_test
  72.     # Loading database for battle test
  73.     $data_actors        = load_data("Data/BT_Actors.rxdata")
  74.     $data_classes       = load_data("Data/BT_Classes.rxdata")
  75.     $data_skills        = load_data("Data/BT_Skills.rxdata")
  76.     $data_items         = load_data("Data/BT_Items.rxdata")
  77.     $data_weapons       = load_data("Data/BT_Weapons.rxdata")
  78.     $data_armors        = load_data("Data/BT_Armors.rxdata")
  79.     $data_enemies       = load_data("Data/BT_Enemies.rxdata")
  80.     $data_troops        = load_data("Data/BT_Troops.rxdata")
  81.     $data_states        = load_data("Data/BT_States.rxdata")
  82.     $data_animations    = load_data("Data/BT_Animations.rxdata")
  83.     $data_tilesets      = load_data("Data/BT_Tilesets.rxdata")
  84.     $data_common_events = load_data("Data/BT_CommonEvents.rxdata")
  85.     $data_system        = load_data("Data/BT_System.rxdata")
  86.     # reset game timer counter
  87.     Graphics.frame_count = 0
  88.     # anylize game objects
  89.     $game_temp          = Game_Temp.new
  90.     $game_system        = Game_System.new
  91.     $game_switches      = Game_Switches.new
  92.     $game_variables     = Game_Variables.new
  93.     $game_self_switches = Game_SelfSwitches.new
  94.     $game_screen        = Game_Screen.new
  95.     $game_actors        = Game_Actors.new
  96.     $game_party         = Game_Party.new
  97.     $game_troop         = Game_Troop.new
  98.     $game_map           = Game_Map.new
  99.     $game_player        = Game_Player.new
  100.     # setup parties used to battle test
  101.     $game_party.setup_battle_test_members
  102.     # setup troop ID, can escape mark, battle background.
  103.     $game_temp.battle_troop_id = $data_system.test_troop_id
  104.     $game_temp.battle_can_escape = true
  105.     $game_map.battleback_name = $data_system.battleback_name
  106.     # play battle start SE
  107.     $game_system.se_play($data_system.battle_start_se)
  108.     # play battle BGM
  109.     $game_system.bgm_play($game_system.battle_bgm)
  110.     # move to battle scene
  111.     $scene = Scene_Battle.new
  112.   end
  113. end
复制代码





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