Project1
标题: 一个朋友写的标题特效脚本 出现了BUG [打印本页]
作者: 涵影_博 时间: 2014-11-9 19:49
标题: 一个朋友写的标题特效脚本 出现了BUG
本帖最后由 涵影_博 于 2014-11-9 19:52 编辑
@cinderelmini 这个问题有点严重
class Window_TitleLogo < Window_Base
CLEAR_FILE = '通关存档名字.格式'
SLIDE_COUNT = {:chn => 60.0, :eng => 90.0}
POS_TEXT = -10
POS_LINE = -50
def initialize
super(0, 0, 24, 24)
self.visible = false
@logo = {}
@logo[:那份] = Sprite.new
@logo[:那份].x = 0
@logo[:那份].y = POS_TEXT
@logo[:泪水] = Sprite.new
@logo[:泪水].x = 0
@logo[:泪水].y = POS_TEXT
@logo[:竟是永恒] = Sprite.new
@logo[:竟是永恒].x = 0
@logo[:竟是永恒].y = POS_TEXT
@logo[:横线] = Sprite.new
@logo[:横线].x = POS_LINE
@logo[:横线].y = 0
@logo[:that] = Sprite.new
@logo[:that].x = POS_TEXT
@logo[:that].y = 0
@logo[:tear] = Sprite.new
@logo[:tear].x = POS_TEXT
@logo[:tear].y = 0
@logo[:last_forever] = Sprite.new
@logo[:last_forever].x = POS_TEXT
@logo[:last_forever].y = 0
@logo[:copyright] = Sprite.new
@logo[:ver] = Sprite.new
@logo.each_key{|key|; @logo[key].opacity = 0; get_logo_bitmap(key)}
end
def dispose
super
@logo.each_value{|a| a.dispose}
end
def clear?
return !Dir.glob(CLEAR_FILE).empty?
end
def get_logo_bitmap(key)
case key
when :那份
bitmap = Cache.picture("TLS-Title-01")
when :泪水
bitmap = Cache.picture("TLS-True-Title-01")
when :竟是永恒
bitmap = Cache.picture("TLS-Title-02")
when :横线
bitmap = Cache.picture("TLS-Title-Line")
when :that
bitmap = Cache.picture("TLS-Title-03")
when :tear
bitmap = Cache.picture("TLS-True-Title-02")
when :last_forever
bitmap = Cache.picture("TLS-Title-04")
when :copyright
bitmap = Cache.picture("TLS-Title-C")
when :ver
bitmap = Cache.picture("TLS-Title-Alpha")
end
@logo[key].bitmap = bitmap
end
def calc_target(start_val, end_val, percent)
return start_val + ((end_val - start_val) * percent)
end
def refresh
d = SLIDE_COUNT[:chn]
count = 0
loop do
percent = count / d
@logo[:那份].y = calc_target(POS_TEXT, 0, percent)
@logo[:那份].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(60)
if clear?
count = 0
loop do
percent = count / d
@logo[:泪水].y = calc_target(POS_TEXT, 0, percent)
@logo[:泪水].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(60)
end
count = 0
loop do
percent = count / d
@logo[:竟是永恒].y = calc_target(POS_TEXT, 0, percent)
@logo[:竟是永恒].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(60)
count = 0
loop do
percent = count / d
@logo[:横线].x = calc_target(POS_LINE, 0, percent)
@logo[:横线].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(60)
d = SLIDE_COUNT[:eng]
count = 0
loop do
percent = count / d
@logo[:that].x = calc_target(POS_TEXT, 0, percent)
@logo[:that].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(30)
if clear?
count = 0
loop do
percent = count / d
@logo[:tear].x = calc_target(POS_TEXT, 0, percent)
@logo[:tear].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(30)
end
count = 0
loop do
percent = count / d
@logo[:last_forever].x = calc_target(POS_TEXT, 0, percent)
@logo[:last_forever].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(30)
count = 0
loop do
percent = count / d
@logo[:copyright].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
count = 0
loop do
percent = count / d
@logo[:ver].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(60)
end
def wait(count)
count.times{|i| Graphics.update}
end
end
class Window_TitleLogo < Window_Base
CLEAR_FILE = '通关存档名字.格式'
SLIDE_COUNT = {:chn => 60.0, :eng => 90.0}
POS_TEXT = -10
POS_LINE = -50
def initialize
super(0, 0, 24, 24)
self.visible = false
@logo = {}
@logo[:那份] = Sprite.new
@logo[:那份].x = 0
@logo[:那份].y = POS_TEXT
@logo[:泪水] = Sprite.new
@logo[:泪水].x = 0
@logo[:泪水].y = POS_TEXT
@logo[:竟是永恒] = Sprite.new
@logo[:竟是永恒].x = 0
@logo[:竟是永恒].y = POS_TEXT
@logo[:横线] = Sprite.new
@logo[:横线].x = POS_LINE
@logo[:横线].y = 0
@logo[:that] = Sprite.new
@logo[:that].x = POS_TEXT
@logo[:that].y = 0
@logo[:tear] = Sprite.new
@logo[:tear].x = POS_TEXT
@logo[:tear].y = 0
@logo[:last_forever] = Sprite.new
@logo[:last_forever].x = POS_TEXT
@logo[:last_forever].y = 0
@logo[:copyright] = Sprite.new
@logo[:ver] = Sprite.new
@logo.each_key{|key|; @logo[key].opacity = 0; get_logo_bitmap(key)}
end
def dispose
super
@logo.each_value{|a| a.dispose}
end
def clear?
return !Dir.glob(CLEAR_FILE).empty?
end
def get_logo_bitmap(key)
case key
when :那份
bitmap = Cache.picture("TLS-Title-01")
when :泪水
bitmap = Cache.picture("TLS-True-Title-01")
when :竟是永恒
bitmap = Cache.picture("TLS-Title-02")
when :横线
bitmap = Cache.picture("TLS-Title-Line")
when :that
bitmap = Cache.picture("TLS-Title-03")
when :tear
bitmap = Cache.picture("TLS-True-Title-02")
when :last_forever
bitmap = Cache.picture("TLS-Title-04")
when :copyright
bitmap = Cache.picture("TLS-Title-C")
when :ver
bitmap = Cache.picture("TLS-Title-Alpha")
end
@logo[key].bitmap = bitmap
end
def calc_target(start_val, end_val, percent)
return start_val + ((end_val - start_val) * percent)
end
def refresh
d = SLIDE_COUNT[:chn]
count = 0
loop do
percent = count / d
@logo[:那份].y = calc_target(POS_TEXT, 0, percent)
@logo[:那份].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(60)
if clear?
count = 0
loop do
percent = count / d
@logo[:泪水].y = calc_target(POS_TEXT, 0, percent)
@logo[:泪水].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(60)
end
count = 0
loop do
percent = count / d
@logo[:竟是永恒].y = calc_target(POS_TEXT, 0, percent)
@logo[:竟是永恒].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(60)
count = 0
loop do
percent = count / d
@logo[:横线].x = calc_target(POS_LINE, 0, percent)
@logo[:横线].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(60)
d = SLIDE_COUNT[:eng]
count = 0
loop do
percent = count / d
@logo[:that].x = calc_target(POS_TEXT, 0, percent)
@logo[:that].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(30)
if clear?
count = 0
loop do
percent = count / d
@logo[:tear].x = calc_target(POS_TEXT, 0, percent)
@logo[:tear].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(30)
end
count = 0
loop do
percent = count / d
@logo[:last_forever].x = calc_target(POS_TEXT, 0, percent)
@logo[:last_forever].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(30)
count = 0
loop do
percent = count / d
@logo[:copyright].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
count = 0
loop do
percent = count / d
@logo[:ver].opacity = calc_target(0, 255, percent)
count += 1
Graphics.update
break if count >= d
end
wait(60)
end
def wait(count)
count.times{|i| Graphics.update}
end
end
#encoding:utf-8
#==============================================================================
# ■ Window_TitleCommand
#------------------------------------------------------------------------------
# 标题画面中,选择“开始游戏/继续游戏”的窗口。
#==============================================================================
class Window_TitleCommand < Window_Command
COUNT = 30.0
def make_command
@command = []
for i in 0...item_max
@command[i] = Window_TitleSub.new(command_name(i), false)
end
end
def refresh_command
@command.each{|a|
count = 0
loop do
percent = count / COUNT
a.x = calc_target(-30, 0, percent)
a.opacity = calc_target(0, 255, percent)
count += 1
SceneManager.scene.update
if count >= COUNT
a.open = true
break
end
end
}
end
def dispose
super
@command.each{|a| a.dispose}
end
def select(index)
@command[self.index].refresh(false) if @command
wait(15, self.index) if @command
super(index)
@command[self.index].refresh(true) if @command
end
def update
super
return unless @command
@command.each{|a| a.update}
end
def wait(count, index = nil)
count.times{|i| @command[index].update if index; SceneManager.scene.update}
end
def calc_target(start_val, end_val, percent)
return start_val + ((end_val - start_val) * percent)
end
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
super(0, 0)
self.visible = false
select_symbol(:continue) if continue_enabled
end
def draw_item(i)
end
#--------------------------------------------------------------------------
# ● 生成指令列表
#--------------------------------------------------------------------------
def make_command_list
add_command(Vocab::new_game, :new_game)
add_command(Vocab::continue, :continue, continue_enabled)
add_command(Vocab::shutdown, :shutdown)
make_command
end
end
#encoding:utf-8
#==============================================================================
# ■ Window_TitleCommand
#------------------------------------------------------------------------------
# 标题画面中,选择“开始游戏/继续游戏”的窗口。
#==============================================================================
class Window_TitleCommand < Window_Command
COUNT = 30.0
def make_command
@command = []
for i in 0...item_max
@command[i] = Window_TitleSub.new(command_name(i), false)
end
end
def refresh_command
@command.each{|a|
count = 0
loop do
percent = count / COUNT
a.x = calc_target(-30, 0, percent)
a.opacity = calc_target(0, 255, percent)
count += 1
SceneManager.scene.update
if count >= COUNT
a.open = true
break
end
end
}
end
def dispose
super
@command.each{|a| a.dispose}
end
def select(index)
@command[self.index].refresh(false) if @command
wait(15, self.index) if @command
super(index)
@command[self.index].refresh(true) if @command
end
def update
super
return unless @command
@command.each{|a| a.update}
end
def wait(count, index = nil)
count.times{|i| @command[index].update if index; SceneManager.scene.update}
end
def calc_target(start_val, end_val, percent)
return start_val + ((end_val - start_val) * percent)
end
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
super(0, 0)
self.visible = false
select_symbol(:continue) if continue_enabled
end
def draw_item(i)
end
#--------------------------------------------------------------------------
# ● 生成指令列表
#--------------------------------------------------------------------------
def make_command_list
add_command(Vocab::new_game, :new_game)
add_command(Vocab::continue, :continue, continue_enabled)
add_command(Vocab::shutdown, :shutdown)
make_command
end
end
class Window_TitleSub < Window_Base
POS = [-35, 35]
COUNT = 30.0
attr_accessor :open
def initialize(item = nil, on = false)
super(0, 0, 24, 24)
[url=home.php?mod=space&uid=257928]@open[/url] = false
@on = on
@ani_count = COUNT
@command = []
@command[0] = Sprite.new
@command[1] = Sprite.new
case item
when Vocab::new_game
bitmap = "TLS-Title-Start-"
when Vocab::continue
bitmap = "TLS-Title-Continue-"
when Vocab::shutdown
bitmap = "TLS-Title-Exit-"
end
@command[0].bitmap = Cache.picture(bitmap + "0")
@command[0].opacity = 0
@command[1].bitmap = Cache.picture(bitmap + "1")
@command[1].opacity = 0
self.visible = false
self.x = -30
end
def x=(n)
super(0)
@command[0].x = n
@command[1].x = n
end
def opacity=(n)
super(n)
@command[0].opacity = n
end
def dispose
super
@command.each{|a| a.dispose}
end
def refresh(on = @on)
@on = on
@ani_count = 0
end
def calc_target(start_val, end_val, percent)
return start_val + ((end_val - start_val) * percent)
end
def update
super
update_command
end
def _open?
return @open
end
def update_command
return unless _open?
if @on
if @ani_count < COUNT
percent = @ani_count / COUNT
@command[0].x = calc_target(0, POS[1], percent)
@command[0].opacity = calc_target(255, 0, percent)
@command[1].x = calc_target(POS[0], 0, percent)
@command[1].opacity = calc_target(0, 255, percent)
@ani_count += 1
else
@command[0].x = POS[0]
@command[0].opacity = 0
@command[1].x = 0
@command[1].opacity = 255
end
else
if @ani_count < COUNT
percent = @ani_count / COUNT
@command[1].x = calc_target(0, POS[1], percent)
@command[1].opacity = calc_target(255, 0, percent)
@command[0].x = calc_target(POS[0], 0, percent)
@command[0].opacity = calc_target(0, 255, percent)
@ani_count += 1
else
@command[1].x = POS[0]
@command[1].opacity = 0
@command[0].x = 0
@command[0].opacity = 255
end
end
end
end
class Window_TitleSub < Window_Base
POS = [-35, 35]
COUNT = 30.0
attr_accessor :open
def initialize(item = nil, on = false)
super(0, 0, 24, 24)
[url=home.php?mod=space&uid=257928]@open[/url] = false
@on = on
@ani_count = COUNT
@command = []
@command[0] = Sprite.new
@command[1] = Sprite.new
case item
when Vocab::new_game
bitmap = "TLS-Title-Start-"
when Vocab::continue
bitmap = "TLS-Title-Continue-"
when Vocab::shutdown
bitmap = "TLS-Title-Exit-"
end
@command[0].bitmap = Cache.picture(bitmap + "0")
@command[0].opacity = 0
@command[1].bitmap = Cache.picture(bitmap + "1")
@command[1].opacity = 0
self.visible = false
self.x = -30
end
def x=(n)
super(0)
@command[0].x = n
@command[1].x = n
end
def opacity=(n)
super(n)
@command[0].opacity = n
end
def dispose
super
@command.each{|a| a.dispose}
end
def refresh(on = @on)
@on = on
@ani_count = 0
end
def calc_target(start_val, end_val, percent)
return start_val + ((end_val - start_val) * percent)
end
def update
super
update_command
end
def _open?
return @open
end
def update_command
return unless _open?
if @on
if @ani_count < COUNT
percent = @ani_count / COUNT
@command[0].x = calc_target(0, POS[1], percent)
@command[0].opacity = calc_target(255, 0, percent)
@command[1].x = calc_target(POS[0], 0, percent)
@command[1].opacity = calc_target(0, 255, percent)
@ani_count += 1
else
@command[0].x = POS[0]
@command[0].opacity = 0
@command[1].x = 0
@command[1].opacity = 255
end
else
if @ani_count < COUNT
percent = @ani_count / COUNT
@command[1].x = calc_target(0, POS[1], percent)
@command[1].opacity = calc_target(255, 0, percent)
@command[0].x = calc_target(POS[0], 0, percent)
@command[0].opacity = calc_target(0, 255, percent)
@ani_count += 1
else
@command[1].x = POS[0]
@command[1].opacity = 0
@command[0].x = 0
@command[0].opacity = 255
end
end
end
end
class Scene_Title < Scene_Base
def post_start
super
@logo.refresh
@command_window.refresh_command
end
alias shiina_c_c_w create_command_window
def create_command_window
@logo = Window_TitleLogo.new
shiina_c_c_w
end
end
class Scene_Title < Scene_Base
def post_start
super
@logo.refresh
@command_window.refresh_command
end
alias shiina_c_c_w create_command_window
def create_command_window
@logo = Window_TitleLogo.new
shiina_c_c_w
end
end
一共是上面四段脚本
我希望出现的效果在事件标题已经做到了 但是现在转到脚本上有点问题
第一是选项滑动开始的时候开始和退出会同时滚动
第二是如果按住上/下键会出现鬼畜效果
选项滑动在事件中有样子已经提供工程附件
跳过标题脚本已经禁用
望大神指点
链接: http://pan.baidu.com/s/1jGA9uLo 密码: 1iow
@taroxd @喵呜喵5 @VIPArcher
作者: cinderelmini 时间: 2014-11-9 20:22
呵呵呵……………………
反正这组脚本窝写到这里是不想再修惹~
初始居然会select一下最后一项简直WTF~暂时找不到原因中~
作者: 喵呜喵5 时间: 2014-11-10 17:06
cinderelmini 发表于 2014-11-9 20:22
呵呵呵……………………
反正这组脚本窝写到这里是不想再修惹~
初始居然会select一下最后一项简直WTF~暂时 ...
Window_TitleCommand- def select(index)
- @command[self.index].refresh(false) if @command
- wait(15, self.index) if @command
- super(index)
- @command[self.index].refresh(true) if @command
- end
复制代码 问题出在这个方法的第一句:- @command[self.index].refresh(false) if @command
复制代码 当一个command窗口载入的时候,其self.index被设置成了-1,而数组中使用负数作为索引实际上等于倒着往前,于是于是第一次执行select方法的时候所做的事情就是:
- 结束游戏.refresh(false) if @command
- wait(15, self.index) if @command
- super(1)
- 开始游戏.refresh(true) if @command
复制代码 而refresh方法将结束游戏的@ani_count设置成了0,于是结束游戏自然就会开始update了……
解决方法有很多,例如修改initialize方法变成这个样子:- def initialize
- super(0, 0)
- self.visible = false
- select_symbol(:continue) if continue_enabled
- @command[-1].instance_variable_set(:@ani_count, 30000)
- end
复制代码 同理,select_symbol(:continue) if continue_enabled 这句代码也将造成上面提到的问题,不过既然已经知道问题的来源了修改这个应该不难吧
至于选项鬼畜抖动的……
类似这样把下面这段代码扔进Scene_Title里面,强制等待特效结束后才允许玩家按键就好了(或者玩家每次按键结束后强制等待一段时间也可以)- class Window_TitleCommand
- def cursor_movable?
- result = super
- return false unless result
- @command.each{|c| return false if c.m5_effect?}
- true
- end
- end
- class Window_TitleSub
- def m5_effect?
- return @ani_count < COUNT
- end
- end
复制代码
作者: 涵影_博 时间: 2014-11-10 17:35
喵呜喵5 发表于 2014-11-10 17:06
Window_TitleCommand问题出在这个方法的第一句:当一个command窗口载入的时候,其self.index被设置成了-1 ...
感谢喵5前辈啦 而且这个标题特效只会出现两次啦…… @cinderelmini
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |