查看: 3876|回复: 2

[RMVX发布] 聪聪的多人烛光系统(献给苏联君的礼物)

[复制链接]

聪仔

梦石
0
星屑
6187
在线时间
3077 小时
注册时间
2013-12-26
回帖
3076
发表于 2016-5-11 15:45:01 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 正太君 于 2016-5-11 15:57 编辑

常规办法蒙一张镂空的光斑图只能处理简单的单人烛光效果,若是多人烛光效果就没法实现了呢...
于是苏联君,聪聪给你献上礼物了,希望你会喜欢,
【使用方法】
【事件脚本】输入:
  $game_system.candle_ch_new = [0,x,y,z...]
  0表示主角,x,y,z...表示事件编号,所有涉及的角色和事件周围会有烛光效果...
【事件脚本】输入:
  $game_system.candle_ch_new = []
  取消烛光效果显示,但环境仍然黑暗...
【事件脚本】输入:
  $game_system.candle_ch_new = nil
  取消烛光效果显示,且环境亮度还原...


上效果图...
1.PNG
2.PNG

上范例...
Project3.rar (250.08 KB, 下载次数: 177)

上脚本...
[pre lang="ruby"]#==============================================================================
# ■ 聪聪的多人烛光系统
#------------------------------------------------------------------------------
#   使用方法:
#
#    【事件脚本】输入:
#    $game_system.candle_ch_new = [0,x,y,z...]
#    0表示主角,x,y,z...表示事件编号,所有涉及的角色和事件周围会有烛光效果...
#
#    【事件脚本】输入:
#    $game_system.candle_ch_new = []
#    取消烛光效果显示,但环境仍然黑暗...
#
#    【事件脚本】输入:
#    $game_system.candle_ch_new = nil
#    取消烛光效果显示,且环境亮度还原...
#
#------------------------------------------------------------------------------
#  
#    转载请保留脚本来源:本脚本来自rpg.blue
#                                                        作者:聪聪(正太君)
#                                                                2016-05-11
#==============================================================================
class Candle
  # 设置暗处不透明度(0-255)...
  OPACITY = 128
  # 设置昏暗度(0-255)...
  DARK = 200
  #--------------------------------------------------------------------------
  # ● # 生成黑暗背景和烛光
  #--------------------------------------------------------------------------
  def candlelight
    @black_rect = Sprite.new
    @black_rect.bitmap = Bitmap.new(Graphics.width, Graphics.height)
    @black_rect.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(DARK, DARK, DARK))
    @black_rect.blend_type = 2
    @black_rect.opacity = OPACITY
    @candle_rect = Sprite.new
    @candle_rect.bitmap = Cache.picture("Light0")
    @candle_rect.visible = false
    @candle_rect.ox = @candle_rect.bitmap.width / 2
    @candle_rect.oy = @candle_rect.bitmap.height / 2
  end
  #--------------------------------------------------------------------------
  # ● 设置有烛光的角色
  #--------------------------------------------------------------------------
  def set_candles(candle_ch)
    return if candle_ch == nil
    chs = candle_ch
    @game_lighterlist = [] if @game_lighterlist.nil?
    @game_lighterlist << $game_player if chs.include?(0)
    chs.each {|i| @game_lighterlist << $game_map.events if i != 0}
    # 移除重复的角色
    @game_lighterlist.uniq!
    # 开启烛光功能
    candlelight
  end
  #--------------------------------------------------------------------------
  # ● 初始化烛光
  #--------------------------------------------------------------------------
  def initialize_candle(ch)
    lsx = @candle_rect.x = ch.screen_x - @candle_rect.ox
    lsy = @candle_rect.y = ch.screen_y - @candle_rect.oy - 16
    @black_rect.bitmap.blt(lsx, lsy, @candle_rect.bitmap, @black_rect.bitmap.rect)
  end
  #--------------------------------------------------------------------------
  # ● 更新烛光
  #--------------------------------------------------------------------------
  def update_candle
    if $game_system.candle_ch == $game_system.candle_ch_new and @black_rect
      @black_rect.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(DARK, DARK, DARK))
      @game_lighterlist.each {|i| initialize_candle(i)}
    else
      dispose_candle
    end
  end
  #--------------------------------------------------------------------------
  # ● 释放烛光
  #--------------------------------------------------------------------------
  def dispose_candle
    @black_rect.dispose if @black_rect
    @candle_rect.dispose if @candle_rect
    @game_lighterlist.clear if @game_lighterlist
  end  
end

class Scene_Map < Scene_Base
  attr_reader   :candle
  #--------------------------------------------------------------------------
  # ● 开始后处理
  #--------------------------------------------------------------------------
  def post_start
    @candle = Candle.new
    @candle.set_candles($game_system.candle_ch)
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  alias :o_update :update
  def update
    o_update
    if $game_system.candle_ch != $game_system.candle_ch_new
      @candle.dispose_candle
      $game_system.candle_ch = $game_system.candle_ch_new
      @candle = Candle.new
      @candle.set_candles($game_system.candle_ch)
    end
    @candle.update_candle
  end
end

class Game_System
attr_accessor :candle_ch
attr_accessor :candle_ch_new
end[/pre]

评分

参与人数 4星屑 +643 收起 理由
NOLO + 10 感谢分享
天使喝可乐 + 66 塞糖
zaiy2863 + 47 今天的糖都给你
Password + 520 聪聪又变帅了w

查看全部评分

聪聪全国第三帅...
他们都叫我【人赢聪】
我的RM能力雷达图:

梦石
0
星屑
2391
在线时间
54 小时
注册时间
2011-11-23
回帖
4
发表于 2016-6-7 23:01:34 | 显示全部楼层
无敌啊。。。。。。。。。。。。。。。。。。。。。。。。
回复

使用道具 举报

梦石
0
星屑
384
在线时间
145 小时
注册时间
2013-6-11
回帖
63
发表于 2016-12-3 19:34:22 | 显示全部楼层
感谢分享
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部