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

Project1

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

[已经解决] 显示Logo画面死循环

[复制链接]

Lv1.梦旅人

梦石
0
星屑
60
在线时间
317 小时
注册时间
2009-1-18
帖子
177
跳转到指定楼层
1
发表于 2012-5-9 13:14:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
游戏进入前先显示Logo,虽然一搜索就一堆,可是还是想自己做一个,就当是熟悉一下Scene这边工作的流程吧。
于是自己写了一个Scene_Logo,用Ace想实现。
可是一开始就卡住了,就是一直黑屏,然后程序就没有相应了……
目测……死循环……?但是自己找了很久也没有发觉错误的地方……
所以……想求助一下
  1. # encoding: utf-8
  2. #------------------------------------------------------------------------------
  3. # * Add Get Logo Graphic Function to Cache
  4. #------------------------------------------------------------------------------
  5. module Cache
  6.   #--------------------------------------------------------------------------
  7.   # * Get Logo Graphic
  8.   #--------------------------------------------------------------------------
  9.   def self.logo(filename)
  10.     load_bitmap("Graphics/Logos/", filename)
  11.   end
  12. end

  13. #------------------------------------------------------------------------------
  14. # * Add Scene Logo to SceneManager
  15. #------------------------------------------------------------------------------
  16. module SceneManager
  17.   #--------------------------------------------------------------------------
  18.   # * Execute
  19.   #--------------------------------------------------------------------------
  20.   def self.run
  21.     DataManager.init
  22.     Audio.setup_midi if use_midi?
  23.     @scene = first_scene_class.new
  24.     @scene.main while @scene
  25.     @scene = second_scene_class.new
  26.     @scene.main while @scene
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # * Get First Scene Class
  30.   #--------------------------------------------------------------------------
  31.   def self.first_scene_class
  32.     $BTEST ? Scene_Battle : Scene_Logo
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # * Get Second Scene Class
  36.   #--------------------------------------------------------------------------
  37.   def self.second_scene_class
  38.     $BTEST ? Scene_Battle : Scene_Title
  39.   end
  40. end

  41. #------------------------------------------------------------------------------
  42. # * Scene Logo
  43. #------------------------------------------------------------------------------
  44. class Scene_Logo < Scene_Base
  45.   #--------------------------------------------------------------------------
  46.   # * Start Processing
  47.   #--------------------------------------------------------------------------
  48.   def start
  49.     super
  50.     SceneManager.clear
  51.     Graphics.freeze
  52.     p "run"
  53.     create_logo
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # * Get Transition Speed
  57.   #--------------------------------------------------------------------------
  58.   def transition_speed
  59.     return 20
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # * Termination Processing
  63.   #--------------------------------------------------------------------------
  64.   def terminate
  65.     super
  66.     SceneManager.snapshot_for_background
  67.     @sprite.bitmap.dispose
  68.     @sprite.dispose
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # * Create Logo
  72.   #--------------------------------------------------------------------------
  73.   def create_logo
  74.     @sprite = Sprite.new
  75.     @sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
  76.     @sprite.opacity = 0
  77.     @delay = 500
  78.     @logo_number = 1
  79.     check_logo
  80.     show_logo
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # * Check Logo
  84.   #--------------------------------------------------------------------------
  85.   def check_logo
  86.     if FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.png") ||
  87.       FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.bmp") ||
  88.       FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.jpg")
  89.       @sprite.bitmap = Cache.logo("Logo#{@logo_number}")
  90.     else
  91.       $scene = Scene_Title.new
  92.     end
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # * Show Logo
  96.   #--------------------------------------------------------------------------
  97.   def show_logo
  98.     p "show_logo"
  99.     Graphics.transition(transition_speed)
  100.     until $scene != self
  101.       Graphics.update
  102.       Input.update
  103.       update
  104.     end
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # * Frame Update
  108.   #--------------------------------------------------------------------------
  109.   def update
  110.     if @delay > 372
  111.       opacity = 2
  112.     elsif @delay <= 128
  113.       opacity = -2
  114.     else
  115.       opacity = 0
  116.     end
  117.     @sprite.opacity += opacity
  118.     @delay -= 1
  119.     @sprite.update
  120.     if @delay == 0 || Input.trigger?(Input::B)
  121.       @logo_number += 1
  122.       if FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.png") ||
  123.         FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.bmp") ||
  124.         FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.jpg")
  125.         @sprite.opacity = 0
  126.         @sprite.bitmap = Cache.logo("Logo#{@logo_number}")
  127.         @delay = 500
  128.       else
  129.         $scene = Scene_Title.new
  130.       end
  131.     end
  132.   end
  133. end
复制代码
当然也可能不是死循环的问题……所以……问题出在哪?

Lv3.寻梦者

梦石
0
星屑
1641
在线时间
2205 小时
注册时间
2010-6-27
帖子
1299
2
发表于 2012-5-10 11:27:47 | 只看该作者
本帖最后由 pigsss 于 2012-5-10 11:29 编辑
  1. # encoding: utf-8
  2. #------------------------------------------------------------------------------
  3. # * Add Get Logo Graphic Function to Cache
  4. #------------------------------------------------------------------------------
  5. module Cache
  6.   #--------------------------------------------------------------------------
  7.   # * Get Logo Graphic
  8.   #--------------------------------------------------------------------------
  9.   def self.logo(filename)
  10.     load_bitmap("Graphics/Logos/", filename)
  11.   end
  12. end

  13. #------------------------------------------------------------------------------
  14. # * Add Scene Logo to SceneManager
  15. #------------------------------------------------------------------------------
  16. module SceneManager
  17.   #--------------------------------------------------------------------------
  18.   # * Execute
  19.   #--------------------------------------------------------------------------
  20.   def self.run
  21.     DataManager.init
  22.     Audio.setup_midi if use_midi?
  23.     @scene = first_scene_class.new
  24.     @scene.main while @scene
  25. #~     @scene = second_scene_class.new
  26. #~     @scene.main while @scene
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # * Get First Scene Class
  30.   #--------------------------------------------------------------------------
  31.   def self.first_scene_class
  32.     $BTEST ? Scene_Battle : Scene_Logo
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # * Get Second Scene Class
  36.   #--------------------------------------------------------------------------
  37.   def self.second_scene_class
  38.     $BTEST ? Scene_Battle : Scene_Title
  39.   end
  40. end

  41. #------------------------------------------------------------------------------
  42. # * Scene Logo
  43. #------------------------------------------------------------------------------
  44. class Scene_Logo < Scene_Base
  45.   #--------------------------------------------------------------------------
  46.   # * Start Processing
  47.   #--------------------------------------------------------------------------
  48.   def start
  49.     super
  50.     SceneManager.clear
  51.     #Graphics.freeze
  52.     p "run"
  53.     create_logo
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # * Get Transition Speed
  57.   #--------------------------------------------------------------------------
  58.   def transition_speed
  59.     return 20
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # * Termination Processing
  63.   #--------------------------------------------------------------------------
  64.   def terminate
  65.     super
  66.     SceneManager.snapshot_for_background
  67.     @sprite.bitmap.dispose
  68.     @sprite.dispose
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # * Create Logo
  72.   #--------------------------------------------------------------------------
  73.   def create_logo
  74.     @sprite = Sprite.new
  75.     @sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
  76.     @sprite.opacity = 0
  77.     @delay = 500
  78.     @logo_number = 1
  79.     check_logo
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # * Check Logo
  83.   #--------------------------------------------------------------------------
  84.   def check_logo
  85.     if FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.png") ||
  86.       FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.bmp") ||
  87.       FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.jpg")
  88.       @sprite.bitmap = Cache.logo("Logo#{@logo_number}")
  89.     else
  90.       $scene = Scene_Title.new
  91.     end
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * Frame Update
  95.   #--------------------------------------------------------------------------
  96.   def update
  97.     super
  98.     if @delay > 372
  99.       opacity = 2
  100.     elsif @delay <= 128
  101.       opacity = -2
  102.     else
  103.       opacity = 0
  104.     end
  105.     @sprite.opacity += opacity
  106.     @delay -= 1
  107.     @sprite.update
  108.     if @delay == 0 || Input.trigger?(Input::B)
  109.       SceneManager.call(Scene_Title)# = Scene_Title.new
  110.     end
  111.   end
  112. end
复制代码
以上·
update 没继承也没把关键点重写进去 - -
场景跳转也没有 - -���

于是我也广告下…
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-22 12:00

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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