查看: 3251|回复: 2

[已经解决] 求助,这个灯光脚本是vx移植过来的出问题了

[复制链接]
梦石
0
星屑
1093
在线时间
881 小时
注册时间
2012-6-28
回帖
972
发表于 2013-10-12 11:41:49 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 没是的人 于 2013-10-12 16:59 编辑

这个脚本出问题了,在vx用的好好的
拿到rgss3了以后估计是精灵类方面的问题
切换场景以后灯光的位置居然不变
但是打开菜单以后再关掉显示就正常了

本脚本使用方法:
picture里放人 le.png
在脚本里插入这些语句
12号开关控制灯是否亮起,在需要亮起的事件里注释
   GROUND - 中等稳定的白光.
   FIRE   - 伴有轻微的闪烁的红色.
   LIGHT  - 小型稳定的白光.
   LIGHT2 -大型稳定的白光.
   TORCH  - 伴有强烈闪烁的大型稳定的红光.
   TORCH2 - 伴有中等烁的大型稳定的红光.


  1.   $lsig = 12           #开关号


  2. class Spriteset_Map
  3.   alias les_spriteset_map_initalize initialize
  4.   alias les_spriteset_map_dispose dispose
  5.   alias les_spriteset_map_update update
  6.   def initialize
  7.     @light_effects = []
  8.     setup_lights
  9.     les_spriteset_map_initalize
  10.     update
  11.   end
  12.   def dispose
  13.     les_spriteset_map_dispose
  14.     for effect in @light_effects
  15.       effect.light.dispose
  16.     end
  17.     @light_effects = []
  18.   end
  19.   def update
  20.     les_spriteset_map_update
  21.     update_light_effects
  22.   end
  23.   def setup_lights
  24.     for event in $game_map.events.values
  25.       next if event.list == nil
  26.       for i in 0...event.list.size
  27.         if event.list[i].code == 108 and event.list[i].parameters == ["GROUND"]
  28.           type = "GROUND"
  29.           light_effects = Light_Effect.new(event,type)
  30.           light_effects.light.zoom_x = 2
  31.           light_effects.light.zoom_y = 2
  32.           light_effects.light.opacity = 100
  33.           @light_effects.push(light_effects)
  34.         end
  35.         if event.list[i].code == 108 and event.list[i].parameters == ["FIRE"]
  36.           type = "FIRE"
  37.           light_effects = Light_Effect.new(event,type)
  38.           light_effects.light.zoom_x = 300 / 100.0
  39.           light_effects.light.zoom_y = 300 / 100.0
  40.           light_effects.light.opacity = 100
  41.           @light_effects.push(light_effects)
  42.         end
  43.         if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT"]
  44.           type = "LIGHT"
  45.           light_effects = Light_Effect.new(event,type)
  46.           light_effects.light.zoom_x = 1
  47.           light_effects.light.zoom_y = 1
  48.           light_effects.light.opacity = 150
  49.           @light_effects.push(light_effects)
  50.         end
  51.         if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT2"]
  52.           type = "LIGHT2"
  53.           light_effects = Light_Effect.new(event,type)
  54.           light_effects.light.zoom_x = 6
  55.           light_effects.light.zoom_y = 6
  56.           light_effects.light.opacity = 150
  57.           @light_effects.push(light_effects)
  58.         end
  59.         if event.list[i].code == 108 and event.list[i].parameters == ["TORCH"]
  60.           type = "TORCH"
  61.           light_effects = Light_Effect.new(event,type)
  62.           light_effects.light.zoom_x = 6
  63.           light_effects.light.zoom_y = 6
  64.           light_effects.light.opacity = 150
  65.           @light_effects.push(light_effects)
  66.         end
  67.         if event.list[i].code == 108 and event.list[i].parameters == ["TORCH2"]
  68.           type = "TORCH2"
  69.           light_effects = Light_Effect.new(event,type)
  70.           light_effects.light.zoom_x = 6
  71.           light_effects.light.zoom_y = 6
  72.           light_effects.light.opacity = 150
  73.           @light_effects.push(light_effects)
  74.         end
  75.       end
  76.     end
  77.     for effect in @light_effects
  78.       case effect.type
  79.       when "GROUND"
  80.         effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  81.         effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  82.         effect.light.blend_type = 1
  83.       when "FIRE"
  84.         effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
  85.         effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
  86.         effect.light.tone = Tone.new(255,-100,-255,   0)
  87.         effect.light.blend_type = 1
  88.       when "LIGHT"
  89.         effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
  90.         effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
  91.         effect.light.blend_type = 1
  92.       when "LIGHT2"
  93.         effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
  94.         effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
  95.         effect.light.blend_type = 1
  96.       when "TORCH"
  97.         effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
  98.         effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
  99.         effect.light.tone = Tone.new(255,-100,-255,   0)
  100.         effect.light.blend_type = 1
  101.       when "TORCH2"
  102.         effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
  103.         effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
  104.         effect.light.tone = Tone.new(255,-100,-255,   0)
  105.         effect.light.blend_type = 1
  106.       end
  107.     end
  108.   end
  109.   def update_light_effects
  110.     if $game_switches[$lsig]
  111.       for effect in @light_effects
  112.         effect.light.visible = false
  113.       end
  114.     else
  115.       for effect in @light_effects

  116.         effect.light.visible = true
  117.       end
  118.     end
  119.     for effect in @light_effects
  120.       case effect.type
  121.       when "GROUND"
  122.         effect.light.x = (effect.event.screen_x * 8 - 400 - $game_map.display_x) / 8 - 8
  123.         effect.light.y = (effect.event.screen_y * 8 - 400 - $game_map.display_y) / 8 - 36
  124.       when "FIRE"
  125.         effect.light.x = (effect.event.screen_x * 8 - 600 - $game_map.display_x) / 8 + rand(6) - 3 - 16
  126.         effect.light.y = (effect.event.screen_y * 8 - 600 - $game_map.display_y) / 8 + rand(6) - 3 - 48
  127.         effect.light.opacity = rand(10) + 90
  128.       when "LIGHT"
  129.         effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
  130.         effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
  131.       when "LIGHT2"
  132.         effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 32
  133.         effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8 - 32
  134.       when "TORCH"
  135.         effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20 + rand(20) - 10
  136.         effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8 + rand(20) - 10
  137.         effect.light.opacity = rand(30) + 70
  138.       when "TORCH2"
  139.         effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20
  140.         effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8
  141.         effect.light.opacity = rand(10) + 90
  142.       end
  143.     end
  144.   end
  145. end

  146. class Light_Effect
  147.   attr_accessor :light
  148.   attr_accessor :event
  149.   attr_accessor :type
  150.   def initialize(event, type)
  151.     [url=home.php?mod=space&uid=22469]@light[/url] = Sprite.new
  152.     @light.bitmap = Cache.picture("le.png")
  153.     @light.visible = true
  154.     @light.z = 1
  155.     @event = event
  156.     @type = type
  157.   end
  158. end
复制代码

出现的主要问题就是:切换场景以后灯光显示不正常,打开一下菜单就正常了
折腾了一上午了就是没解决问题,希望大家帮帮忙,我一定多塞糖

点评

你是怎么产生VX的脚本可以直接在VA上用的错觉的……  发表于 2013-10-12 12:20
不追求华丽的商业素材;不依赖与自己运用能力不符的外挂脚本;不搞华而不实的无用噱头。
                    修改,使用最朴实的素材,融入自己的智慧做最好的游戏!
                                    点这里!暂不设加入门槛
         
                               我觉得我的优点是,会认真的画每一张地图。

梦石
1
星屑
23371
在线时间
9572 小时
注册时间
2012-6-19
回帖
7021

开拓者短篇九导演组冠军

发表于 2013-10-12 13:17:08 | 显示全部楼层

  1.   $lsig = 12           #开关号


  2. class Spriteset_Map
  3.   alias les_spriteset_map_initalize initialize
  4.   alias les_spriteset_map_dispose dispose
  5.   alias les_spriteset_map_update update
  6.   alias m5_spriteset_map_refresh_characters refresh_characters
  7.   def initialize   
  8.     creat_light
  9.     les_spriteset_map_initalize
  10.     update        
  11.   end  
  12.   def dispose
  13.     les_spriteset_map_dispose
  14.     dispose_light
  15.   end  
  16.   def creat_light
  17.     @light_effects = []
  18.     setup_lights   
  19.   end  
  20.   def dispose_light
  21.     for effect in @light_effects
  22.       effect.light.dispose
  23.     end
  24.     @light_effects = []
  25.   end  
  26.   def update   
  27.     les_spriteset_map_update
  28.     update_light_effects
  29.   end
  30.   def refresh_characters
  31.     m5_spriteset_map_refresh_characters
  32.     refresh_light
  33.   end
  34.   def refresh_light
  35.     dispose_light
  36.     creat_light
  37.     update
  38.   end
  39.   
  40.   def setup_lights
  41.     for event in $game_map.events.values
  42.       next if event.list == nil
  43.       for i in 0...event.list.size
  44.         if event.list[i].code == 108 and event.list[i].parameters == ["GROUND"]
  45.           type = "GROUND"
  46.           light_effects = Light_Effect.new(event,type)
  47.           light_effects.light.zoom_x = 2
  48.           light_effects.light.zoom_y = 2
  49.           light_effects.light.opacity = 100
  50.           @light_effects.push(light_effects)
  51.         end
  52.         if event.list[i].code == 108 and event.list[i].parameters == ["FIRE"]
  53.           type = "FIRE"
  54.           light_effects = Light_Effect.new(event,type)
  55.           light_effects.light.zoom_x = 300 / 100.0
  56.           light_effects.light.zoom_y = 300 / 100.0
  57.           light_effects.light.opacity = 100
  58.           @light_effects.push(light_effects)
  59.         end
  60.         if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT"]
  61.           type = "LIGHT"
  62.           light_effects = Light_Effect.new(event,type)
  63.           light_effects.light.zoom_x = 1
  64.           light_effects.light.zoom_y = 1
  65.           light_effects.light.opacity = 150
  66.           @light_effects.push(light_effects)
  67.         end
  68.         if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT2"]
  69.           type = "LIGHT2"
  70.           light_effects = Light_Effect.new(event,type)
  71.           light_effects.light.zoom_x = 6
  72.           light_effects.light.zoom_y = 6
  73.           light_effects.light.opacity = 150
  74.           @light_effects.push(light_effects)
  75.         end
  76.         if event.list[i].code == 108 and event.list[i].parameters == ["TORCH"]
  77.           type = "TORCH"
  78.           light_effects = Light_Effect.new(event,type)
  79.           light_effects.light.zoom_x = 6
  80.           light_effects.light.zoom_y = 6
  81.           light_effects.light.opacity = 150
  82.           @light_effects.push(light_effects)
  83.         end
  84.         if event.list[i].code == 108 and event.list[i].parameters == ["TORCH2"]
  85.           type = "TORCH2"
  86.           light_effects = Light_Effect.new(event,type)
  87.           light_effects.light.zoom_x = 6
  88.           light_effects.light.zoom_y = 6
  89.           light_effects.light.opacity = 150
  90.           @light_effects.push(light_effects)
  91.         end
  92.       end
  93.     end
  94.     for effect in @light_effects
  95.       case effect.type
  96.       when "GROUND"
  97.         effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
  98.         effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
  99.         effect.light.blend_type = 1
  100.       when "FIRE"
  101.         effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
  102.         effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
  103.         effect.light.tone = Tone.new(255,-100,-255,   0)
  104.         effect.light.blend_type = 1
  105.       when "LIGHT"
  106.         effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
  107.         effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
  108.         effect.light.blend_type = 1
  109.       when "LIGHT2"
  110.         effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
  111.         effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
  112.         effect.light.blend_type = 1
  113.       when "TORCH"
  114.         effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
  115.         effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
  116.         effect.light.tone = Tone.new(255,-100,-255,   0)
  117.         effect.light.blend_type = 1
  118.       when "TORCH2"
  119.         effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
  120.         effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
  121.         effect.light.tone = Tone.new(255,-100,-255,   0)
  122.         effect.light.blend_type = 1
  123.       end
  124.     end
  125.   end
  126.   def update_light_effects
  127.     if $game_switches[$lsig]
  128.       for effect in @light_effects
  129.         effect.light.visible = false
  130.       end
  131.     else
  132.       for effect in @light_effects

  133.         effect.light.visible = true
  134.       end
  135.     end
  136.     for effect in @light_effects
  137.       case effect.type
  138.       when "GROUND"
  139.         effect.light.x = (effect.event.screen_x * 8 - 400 - $game_map.display_x) / 8 - 8
  140.         effect.light.y = (effect.event.screen_y * 8 - 400 - $game_map.display_y) / 8 - 36
  141.       when "FIRE"
  142.         effect.light.x = (effect.event.screen_x * 8 - 600 - $game_map.display_x) / 8 + rand(6) - 3 - 16
  143.         effect.light.y = (effect.event.screen_y * 8 - 600 - $game_map.display_y) / 8 + rand(6) - 3 - 48
  144.         effect.light.opacity = rand(10) + 90
  145.       when "LIGHT"
  146.         effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
  147.         effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
  148.       when "LIGHT2"
  149.         effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 32
  150.         effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8 - 32
  151.       when "TORCH"
  152.         effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20 + rand(20) - 10
  153.         effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8 + rand(20) - 10
  154.         effect.light.opacity = rand(30) + 70
  155.       when "TORCH2"
  156.         effect.light.x = (effect.event.screen_x * 8 - 1200 - $game_map.display_x) / 8 - 20
  157.         effect.light.y = (effect.event.screen_y * 8 - 1200 - $game_map.display_y) / 8
  158.         effect.light.opacity = rand(10) + 90
  159.       end
  160.     end
  161.   end
  162. end

  163. class Light_Effect
  164.   attr_accessor :light
  165.   attr_accessor :event
  166.   attr_accessor :type
  167.   def initialize(event, type)
  168.     [url=home.php?mod=space&uid=22469]@light[/url] = Sprite.new
  169.     @light.bitmap = Cache.picture("le.png")
  170.     @light.visible = true
  171.     @light.z = 1
  172.     @event = event
  173.     @type = type
  174.   end  
  175. end
复制代码
记得自己把173行论坛添加的[url]删掉

评分

参与人数 3星屑 +60 梦石 +1 收起 理由
熊喵酱 + 30 好感動~
Sion + 1 太感动了
没是的人 + 30

查看全部评分

回复

使用道具 举报

梦石
0
星屑
1093
在线时间
881 小时
注册时间
2012-6-28
回帖
972
 楼主| 发表于 2013-10-12 16:58:33 | 显示全部楼层
喵呜喵5 发表于 2013-10-12 13:17
记得自己把173行论坛添加的删掉

谢谢,谢谢,谢谢,大好人啊,太感动了

点评

@迷糊的安安  发表于 2013-10-12 17:00
不追求华丽的商业素材;不依赖与自己运用能力不符的外挂脚本;不搞华而不实的无用噱头。
                    修改,使用最朴实的素材,融入自己的智慧做最好的游戏!
                                    点这里!暂不设加入门槛
         
                               我觉得我的优点是,会认真的画每一张地图。
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部