Project1
标题:
显示Logo画面死循环
[打印本页]
作者:
Majirefy
时间:
2012-5-9 13:14
标题:
显示Logo画面死循环
游戏进入前先显示Logo,虽然一搜索就一堆,可是还是想自己做一个,就当是熟悉一下Scene这边工作的流程吧。
于是自己写了一个Scene_Logo,用Ace想实现。
可是一开始就卡住了,就是一直黑屏,然后程序就没有相应了……
目测……死循环……?但是自己找了很久也没有发觉错误的地方……
所以……想求助一下
# encoding: utf-8
#------------------------------------------------------------------------------
# * Add Get Logo Graphic Function to Cache
#------------------------------------------------------------------------------
module Cache
#--------------------------------------------------------------------------
# * Get Logo Graphic
#--------------------------------------------------------------------------
def self.logo(filename)
load_bitmap("Graphics/Logos/", filename)
end
end
#------------------------------------------------------------------------------
# * Add Scene Logo to SceneManager
#------------------------------------------------------------------------------
module SceneManager
#--------------------------------------------------------------------------
# * Execute
#--------------------------------------------------------------------------
def self.run
DataManager.init
Audio.setup_midi if use_midi?
@scene = first_scene_class.new
@scene.main while @scene
@scene = second_scene_class.new
@scene.main while @scene
end
#--------------------------------------------------------------------------
# * Get First Scene Class
#--------------------------------------------------------------------------
def self.first_scene_class
$BTEST ? Scene_Battle : Scene_Logo
end
#--------------------------------------------------------------------------
# * Get Second Scene Class
#--------------------------------------------------------------------------
def self.second_scene_class
$BTEST ? Scene_Battle : Scene_Title
end
end
#------------------------------------------------------------------------------
# * Scene Logo
#------------------------------------------------------------------------------
class Scene_Logo < Scene_Base
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
SceneManager.clear
Graphics.freeze
p "run"
create_logo
end
#--------------------------------------------------------------------------
# * Get Transition Speed
#--------------------------------------------------------------------------
def transition_speed
return 20
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
SceneManager.snapshot_for_background
@sprite.bitmap.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * Create Logo
#--------------------------------------------------------------------------
def create_logo
@sprite = Sprite.new
@sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
@sprite.opacity = 0
@delay = 500
@logo_number = 1
check_logo
show_logo
end
#--------------------------------------------------------------------------
# * Check Logo
#--------------------------------------------------------------------------
def check_logo
if FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.png") ||
FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.bmp") ||
FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.jpg")
@sprite.bitmap = Cache.logo("Logo#{@logo_number}")
else
$scene = Scene_Title.new
end
end
#--------------------------------------------------------------------------
# * Show Logo
#--------------------------------------------------------------------------
def show_logo
p "show_logo"
Graphics.transition(transition_speed)
until $scene != self
Graphics.update
Input.update
update
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if @delay > 372
opacity = 2
elsif @delay <= 128
opacity = -2
else
opacity = 0
end
@sprite.opacity += opacity
@delay -= 1
@sprite.update
if @delay == 0 || Input.trigger?(Input::B)
@logo_number += 1
if FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.png") ||
FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.bmp") ||
FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.jpg")
@sprite.opacity = 0
@sprite.bitmap = Cache.logo("Logo#{@logo_number}")
@delay = 500
else
$scene = Scene_Title.new
end
end
end
end
复制代码
当然也可能不是死循环的问题……所以……问题出在哪? dsu_plus_rewardpost_czw
作者:
pigsss
时间:
2012-5-10 11:27
本帖最后由 pigsss 于 2012-5-10 11:29 编辑
# encoding: utf-8
#------------------------------------------------------------------------------
# * Add Get Logo Graphic Function to Cache
#------------------------------------------------------------------------------
module Cache
#--------------------------------------------------------------------------
# * Get Logo Graphic
#--------------------------------------------------------------------------
def self.logo(filename)
load_bitmap("Graphics/Logos/", filename)
end
end
#------------------------------------------------------------------------------
# * Add Scene Logo to SceneManager
#------------------------------------------------------------------------------
module SceneManager
#--------------------------------------------------------------------------
# * Execute
#--------------------------------------------------------------------------
def self.run
DataManager.init
Audio.setup_midi if use_midi?
@scene = first_scene_class.new
@scene.main while @scene
#~ @scene = second_scene_class.new
#~ @scene.main while @scene
end
#--------------------------------------------------------------------------
# * Get First Scene Class
#--------------------------------------------------------------------------
def self.first_scene_class
$BTEST ? Scene_Battle : Scene_Logo
end
#--------------------------------------------------------------------------
# * Get Second Scene Class
#--------------------------------------------------------------------------
def self.second_scene_class
$BTEST ? Scene_Battle : Scene_Title
end
end
#------------------------------------------------------------------------------
# * Scene Logo
#------------------------------------------------------------------------------
class Scene_Logo < Scene_Base
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
SceneManager.clear
#Graphics.freeze
p "run"
create_logo
end
#--------------------------------------------------------------------------
# * Get Transition Speed
#--------------------------------------------------------------------------
def transition_speed
return 20
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
SceneManager.snapshot_for_background
@sprite.bitmap.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * Create Logo
#--------------------------------------------------------------------------
def create_logo
@sprite = Sprite.new
@sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
@sprite.opacity = 0
@delay = 500
@logo_number = 1
check_logo
end
#--------------------------------------------------------------------------
# * Check Logo
#--------------------------------------------------------------------------
def check_logo
if FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.png") ||
FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.bmp") ||
FileTest.exists?("Graphics/Logos/Logo#{@logo_number}.jpg")
@sprite.bitmap = Cache.logo("Logo#{@logo_number}")
else
$scene = Scene_Title.new
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if @delay > 372
opacity = 2
elsif @delay <= 128
opacity = -2
else
opacity = 0
end
@sprite.opacity += opacity
@delay -= 1
@sprite.update
if @delay == 0 || Input.trigger?(Input::B)
SceneManager.call(Scene_Title)# = Scene_Title.new
end
end
end
复制代码
以上·
update 没继承也没把关键点重写进去 - -
场景跳转也没有 - -���
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1