Project1
标题:
【小脚本】场所移动不淡入淡出
[打印本页]
作者:
小鱼子
时间:
2011-2-27 10:28
标题:
【小脚本】场所移动不淡入淡出
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
# 处理地图画面的类。
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
$game_map.refresh
@spriteset = Spriteset_Map.new
@message_window = Window_Message.new
end
#--------------------------------------------------------------------------
# ● 执行渐变
#--------------------------------------------------------------------------
def perform_transition
if Graphics.brightness == 0 # 战斗後或载入後等
fadein(30)
else # 从菜单中回来等
Graphics.transition(15)
end
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
def terminate
super
if $scene.is_a?(Scene_Battle) # 切换至战斗场景的场合
@spriteset.dispose_characters # 隐藏角色来生成战斗背景
end
snapshot_for_background
@spriteset.dispose
@message_window.dispose
if $scene.is_a?(Scene_Battle) # 切换至战斗场景的场合
perform_battle_transition # 执行战斗渐变
end
end
#--------------------------------------------------------------------------
# ● 基本更新处理
#--------------------------------------------------------------------------
def update_basic
Graphics.update # 更新游戏画面
Input.update # 更新输入信息
$game_map.update # 更新地图
@spriteset.update # 更新活动块组
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
$game_map.interpreter.update # 更新解释器
$game_map.update # 更新地图
$game_player.update # 更新主角
$game_system.update # 更新计时器
@spriteset.update # 更新活动块组
@message_window.update # 更新信息窗口
unless $game_message.visible # 信息窗口显示中除外
update_transfer_player
update_encounter
update_call_menu
update_call_debug
update_scene_change
end
end
#--------------------------------------------------------------------------
# ● 淡入画面
# duration : 时间
# 如果直接使用 Graphics.fadeout 的话会出现一些状况,如天候效果和远景
# 滚动都会被强迫停止,所以用动态的 fade-in 效果会好些。
#--------------------------------------------------------------------------
def fadein(duration)
Graphics.transition(0)
for i in 0..duration-1
Graphics.brightness = 255 * i / duration
update_basic
end
Graphics.brightness = 255
end
#--------------------------------------------------------------------------
# ● 淡出画面
# duration : 时间
# 与上面的 fadein 一样,不是直接调用 Graphics.fadein。
#--------------------------------------------------------------------------
def fadeout(duration)
Graphics.transition(0)
for i in 0..duration-1
Graphics.brightness = 255 - 255 * i / duration
update_basic
end
Graphics.brightness = 0
end
#--------------------------------------------------------------------------
# ● 场所移动处理
#--------------------------------------------------------------------------
def update_transfer_player
return unless $game_player.transfer?
fade = (Graphics.brightness > 0)
#fadeout(30) if fade
@spriteset.dispose # 释放活动块组
$game_player.perform_transfer # 执行场所移动
$game_map.autoplay # 自动更改 BGM 和 BGS
$game_map.update
#Graphics.wait(15)
@spriteset = Spriteset_Map.new # 重新生成活动块组
#fadein(30) if fade
Input.update
end
#--------------------------------------------------------------------------
# ● 遇敌处理
#--------------------------------------------------------------------------
def update_encounter
return if $game_player.encounter_count > 0 # 检查步数
return if $game_map.interpreter.running? # 判断是否有事件正在执行
return if $game_system.encounter_disabled # 判断是否禁止遇敌
troop_id = $game_player.make_encounter_troop_id # 判断敌人队伍
return if $data_troops[troop_id] == nil # 判断队伍是否无效
$game_troop.setup(troop_id)
$game_troop.can_escape = true
$game_temp.battle_proc = nil
$game_temp.next_scene = "battle"
preemptive_or_surprise
end
#--------------------------------------------------------------------------
# ● 判断先下手或被偷袭
#--------------------------------------------------------------------------
def preemptive_or_surprise
actors_agi = $game_party.average_agi
enemies_agi = $game_troop.average_agi
if actors_agi >= enemies_agi
percent_preemptive = 5
percent_surprise = 3
else
percent_preemptive = 3
percent_surprise = 5
end
if rand(100) < percent_preemptive
$game_troop.preemptive = true
elsif rand(100) < percent_surprise
$game_troop.surprise = true
end
end
#--------------------------------------------------------------------------
# ● 判断是否呼叫菜单(按下B键)
#--------------------------------------------------------------------------
def update_call_menu
if Input.trigger?(Input::B)
return if $game_map.interpreter.running? # 判断是否有事件正在执行
return if $game_system.menu_disabled # 判断是否禁止菜单呼叫
$game_temp.menu_beep = true # 设置音效标志
$game_temp.next_scene = "menu"
end
end
#--------------------------------------------------------------------------
# ● 判断是否呼叫DEBUG场景(按下F9键)
#--------------------------------------------------------------------------
def update_call_debug
if $TEST and Input.press?(Input::F9) # 游戏测试并按下F9
$game_temp.next_scene = "debug"
end
end
#--------------------------------------------------------------------------
# ● 执行场景交替
#--------------------------------------------------------------------------
def update_scene_change
return if $game_player.moving? # 判断主角是否移动中
case $game_temp.next_scene
when "battle"
call_battle
when "shop"
call_shop
when "name"
call_name
when "menu"
call_menu
when "save"
call_save
when "debug"
call_debug
when "gameover"
call_gameover
when "title"
call_title
else
$game_temp.next_scene = nil
end
end
#--------------------------------------------------------------------------
# ● 切换至战斗画面
#--------------------------------------------------------------------------
def call_battle
@spriteset.update
Graphics.update
$game_player.make_encounter_count
$game_player.straighten
$game_temp.map_bgm = RPG::BGM.last
$game_temp.map_bgs = RPG::BGS.last
RPG::BGM.stop
RPG::BGS.stop
Sound.play_battle_start
$game_system.battle_bgm.play
$game_temp.next_scene = nil
$scene = Scene_Battle.new
end
#--------------------------------------------------------------------------
# ● 切换至商店画面
#--------------------------------------------------------------------------
def call_shop
$game_temp.next_scene = nil
$scene = Scene_Shop.new
end
#--------------------------------------------------------------------------
# ● 切换至名称输入画面
#--------------------------------------------------------------------------
def call_name
$game_temp.next_scene = nil
$scene = Scene_Name.new
end
#--------------------------------------------------------------------------
# ● 切换至菜单画面
#--------------------------------------------------------------------------
def call_menu
if $game_temp.menu_beep
Sound.play_decision
$game_temp.menu_beep = false
end
$game_temp.next_scene = nil
$scene = Scene_Menu.new
end
#--------------------------------------------------------------------------
# ● 切换至存档画面
#--------------------------------------------------------------------------
def call_save
$game_temp.next_scene = nil
$scene = Scene_File.new(true, false, true)
end
#--------------------------------------------------------------------------
# ● 切换至DEBUG画面
#--------------------------------------------------------------------------
def call_debug
Sound.play_decision
$game_temp.next_scene = nil
$scene = Scene_Debug.new
end
#--------------------------------------------------------------------------
# ● 切换至游戏结束画面
#--------------------------------------------------------------------------
def call_gameover
$game_temp.next_scene = nil
$scene = Scene_Gameover.new
end
#--------------------------------------------------------------------------
# ● 切换至标题画面
#--------------------------------------------------------------------------
def call_title
$game_temp.next_scene = nil
$scene = Scene_Title.new
fadeout(60)
end
#--------------------------------------------------------------------------
# ● 执行战斗渐变
#--------------------------------------------------------------------------
def perform_battle_transition
Graphics.transition(80, "Graphics/System/BattleStart", 80)
Graphics.freeze
end
end
复制代码
作者:
一箭烂YiJL
时间:
2011-2-27 11:07
其实嘛~咱认为太长了,覆盖函数就可以, 插在Scene_Map之下:
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
# 处理地图画面的类。
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# ● 场所移动处理(来自小鱼子上面发的脚本)
#--------------------------------------------------------------------------
def update_transfer_player
return unless $game_player.transfer?
fade = (Graphics.brightness > 0)
#fadeout(30) if fade
@spriteset.dispose # 释放活动块组
$game_player.perform_transfer # 执行场所移动
$game_map.autoplay # 自动更改 BGM 和 BGS
$game_map.update
#Graphics.wait(15)
@spriteset = Spriteset_Map.new # 重新生成活动块组
#fadein(30) if fade
Input.update
end
end
复制代码
作者:
DeathKing
时间:
2011-2-27 16:25
推荐使用剑兰的方法,考虑到玩家可能使用了其他与Scene_Map相关的地图,这样做会使得一些被重定义的方法再次被重定义回默认。
作者:
夕阳武士
时间:
2011-2-28 22:15
这....我怎么觉得以前有过一个.......
作者:
神行者
时间:
2011-7-16 19:41
提示:
作者被禁止或删除 内容自动屏蔽
作者:
精灵使者
时间:
2011-7-16 23:20
本帖最后由 精灵使者 于 2011-7-17 08:52 编辑
精灵的脚本:
module FAY
NO_TRANSPORT_SWITCH = 1 #控制是否不淡入淡出的开关
end
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
# 处理地图画面的类。
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# ● 场所移动处理(来自小鱼子上面发的脚本)
#--------------------------------------------------------------------------
def update_transfer_player
return unless $game_player.transfer?
fade = (Graphics.brightness > 0)
fadeout(30) if !fade and FAY::NO_TRANSPORT_SWITCH
@spriteset.dispose # 释放活动块组
$game_player.perform_transfer # 执行场所移动
$game_map.autoplay # 自动更改 BGM 和 BGS
$game_map.update
Graphics.wait(15) if !FAY::NO_TRANSPORT_SWITCH
@spriteset = Spriteset_Map.new # 重新生成活动块组
fadein(30) if fade and !FAY::NO_TRANSPORT_SWITCH
Input.update
end
end
复制代码
使用方法:main前,默认是1号开关打开的时候,移动时不淡入淡出。
开关号在设定模块里可修改。
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1