sight_shadow.png (12.76 KB, 下载次数: 55)
要用到的图片
# 设置烛光种类数 CANDLE_NUMBER = 2 # 设置控制开关,不用的话设0 CANDLE_SWITCH = 4 #-------------------------------------------------------------------------- # ● 开启或关闭烛光 #-------------------------------------------------------------------------- def candlelight(on=true) $candlelight_on = $game_switches[CANDLE_SWITCH] = on if on # 生成黑色画面 $black_rect = Sprite.new $black_rect.bitmap = Bitmap.new(544, 416) $black_rect.bitmap.fill_rect(0, 0, 544, 416, Color.new(200, 200, 200)) $black_rect.blend_type = 2 # 黑色透明度,决定黑暗的程度 $black_rect.opacity = 180 # 生成烛光 $candle_rect = Array.new(CANDLE_NUMBER+1).map{|sprite| sprite=Sprite.new} #===============================================================================] # 烛光在此设置 #=============================================================================== # 指定第一种烛光 $candle_rect[1].bitmap = Cache.picture("write1") # 指定第二种烛光 $candle_rect[2].bitmap = Cache.picture("write2") #=============================================================================== #=============================================================================== $candle_rect.each {|sprite| if sprite.bitmap sprite.visible = false sprite.ox, sprite.oy = sprite.bitmap.width/2, sprite.bitmap.height/2 end} else # 释放黑色画面和所有烛光 $black_rect.dispose $candle_rect.each {|sprite| sprite.dispose} $game_lighterlist.clear end end #-------------------------------------------------------------------------- # ● 设置有烛光的角色 # candle_index : 烛光编号 # object : 角色编号,可以为数字或是数字数组 #-------------------------------------------------------------------------- def candles(candle_index, object) $game_lighterlist ||= [] $game_lighterlist[candle_index] ||= [] if object.is_a?(Integer) $game_lighterlist[candle_index] << object elsif object.is_a?(Array) $game_lighterlist[candle_index] += object end # 移除重复的角色 $game_lighterlist[candle_index].uniq! # 开启烛光功能 candlelight unless $candlelight_on end #-------------------------------------------------------------------------- # ● 初始化烛光 #-------------------------------------------------------------------------- def initialize_candle for k in 1...$candle_rect.size next unless $game_lighterlist[k] for j in $game_lighterlist[k] ch = j == 0 ? $game_player : $game_map.events[j] $candle_rect[k].x = ch.screen_x $candle_rect[k].y = ch.screen_y - 16 lsx = $candle_rect[k].x - $candle_rect[k].bitmap.width / 2 lsy = $candle_rect[k].y - $candle_rect[k].bitmap.height / 2 $black_rect.bitmap.blt(lsx, lsy, $candle_rect[k].bitmap, $black_rect.bitmap.rect) end end end #-------------------------------------------------------------------------- # ● 更新烛光 #-------------------------------------------------------------------------- def update_candle if $game_lighterlist != [] light = [] $game_lighterlist.each{|i| light+=i if i} light.each do |i| ch = i == 0 ? $game_player : $game_map.events[i] unless ch.moving_judge? $black_rect.bitmap.fill_rect(0, 0, 544, 416, Color.new(200, 200, 200)) initialize_candle end break end end end class Game_Character #-------------------------------------------------------------------------- # ● 判断移动 #-------------------------------------------------------------------------- def moving_judge? return (!stopping? or (@pattern != @original_pattern)) end end class Game_Map #-------------------------------------------------------------------------- # ● 刷新烛光 #-------------------------------------------------------------------------- alias update_candle_system update def update if $candlelight_on update_candle $candlelight_on = false unless $game_switches[CANDLE_SWITCH] candlelight(false) unless $candlelight_on end update_candle_system end end class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # ● 生成烛光 #-------------------------------------------------------------------------- alias candle_system_start start def start candle_system_start candlelight if $candlelight_on initialize_candle if $candlelight_on end end
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |