Project1

标题: 关于真·地震脚本功能. [打印本页]

作者: jhhuang    时间: 2009-6-3 16:08
标题: 关于真·地震脚本功能.
  1. #==============================================================================
  2. # ■ 真·地震                             BY 亿万星辰@2005
  3. #==============================================================================
  4. # ■ Spriteset_Map
  5. #------------------------------------------------------------------------------
  6. #  处理地图画面活动块和元件的类。本类在
  7. # Scene_Map 类的内部使用。
  8. #==============================================================================

  9. class Spriteset_Map
  10. #--------------------------------------------------------------------------
  11. # ● 刷新画面
  12. #--------------------------------------------------------------------------
  13. def update
  14.   # 如果远景与当前情况不同
  15.   if @panorama_name != $game_map.panorama_name or
  16.     @panorama_hue != $game_map.panorama_hue
  17.     @panorama_name = $game_map.panorama_name
  18.     @panorama_hue = $game_map.panorama_hue
  19.     if @panorama.bitmap != nil
  20.     @panorama.bitmap.dispose
  21.     @panorama.bitmap = nil
  22.     end
  23.     if @panorama_name != ""
  24.     @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
  25.     end
  26.     Graphics.frame_reset
  27.   end
  28.   # 如果雾与当前的情况不同
  29.   if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
  30.     @fog_name = $game_map.fog_name
  31.     @fog_hue = $game_map.fog_hue
  32.     if @fog.bitmap != nil
  33.     @fog.bitmap.dispose
  34.     @fog.bitmap = nil
  35.     end
  36.     if @fog_name != ""
  37.     @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
  38.     end
  39.     Graphics.frame_reset
  40.   end
  41.   # 刷新元件地图
  42.   @tilemap.ox = $game_map.display_x / 4
  43.   @tilemap.oy = $game_map.display_y / 4
  44.   @tilemap.update
  45.   # 刷新远景平面
  46.   @panorama.ox = $game_map.display_x / 8
  47.   @panorama.oy = $game_map.display_y / 8
  48.   # 刷新雾平面
  49.   @fog.zoom_x = $game_map.fog_zoom / 100.0
  50.   @fog.zoom_y = $game_map.fog_zoom / 100.0
  51.   @fog.opacity = $game_map.fog_opacity
  52.   @fog.blend_type = $game_map.fog_blend_type
  53.   @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
  54.   @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
  55.   @fog.tone = $game_map.fog_tone
  56.   # 刷新角色精灵光标
  57.   for sprite in @character_sprites
  58.     sprite.update
  59.   end
  60.   # 刷新天候图形
  61.   @weather.type = $game_screen.weather_type
  62.   @weather.max = $game_screen.weather_max
  63.   @weather.ox = $game_map.display_x / 4
  64.   @weather.oy = $game_map.display_y / 4
  65.   @weather.update
  66.   # 刷新图片
  67.   for sprite in @picture_sprites
  68.     sprite.update
  69.   end
  70.   # 刷新计时器精灵光标
  71.   @timer_sprite.update
  72.   # 设置画面的色调与震动位置
  73.    @viewport1.tone = $game_screen.tone
  74.    @viewport1.ox = (-1) ** rand(2) * $game_screen.shake
  75.    @viewport1.oy = (-1) ** rand(2) * $game_screen.shake
  76.   #让图片也可以震动
  77.   @viewport2.tone = $game_screen.tone
  78.   @viewport2.ox = (-1) ** rand(2) * $game_screen.shake
  79.   @viewport2.oy = (-1) ** rand(2) * $game_screen.shake
  80.   #AVG让动画也可以震动
  81.   @viewport3.ox = (-1) ** rand(2) * $game_screen.shake
  82.   @viewport3.oy = (-1) ** rand(2) * $game_screen.shake
  83.   # 设置画面的闪烁色
  84.   #@viewport4.color = $game_screen.flash_color
  85.   # 刷新视图
  86.   @viewport1.update
  87.   @viewport2.update
  88.   @viewport3.update
  89.   #@viewport4.update
  90. end
  91. end

  92. #==============================================================================
  93. # ■ Spriteset_Battle
  94. #------------------------------------------------------------------------------
  95. #  处理战斗画面的活动块的类。本类在 Scene_Battle 类
  96. # 的内部使用。
  97. #==============================================================================

  98. class Spriteset_Battle
  99. #--------------------------------------------------------------------------
  100. # ● 刷新画面
  101. #--------------------------------------------------------------------------
  102. def update
  103.   # 刷新角色的活动块 (对应角色的替换)
  104.   @actor_sprites[0].battler = $game_party.actors[0]
  105.   @actor_sprites[1].battler = $game_party.actors[1]
  106.   @actor_sprites[2].battler = $game_party.actors[2]
  107.   @actor_sprites[3].battler = $game_party.actors[3]
  108.   # 如果战斗背景文件名与当下不同
  109.   if @battleback_name != $game_temp.battleback_name
  110.     @battleback_name = $game_temp.battleback_name
  111.     if @battleback_sprite.bitmap != nil
  112.     @battleback_sprite.bitmap.dispose
  113.     end
  114.     @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  115.     @battleback_sprite.src_rect.set(0, 0, 640, 320)
  116.   end
  117.   # 刷新战斗者的精灵光标
  118.   for sprite in @enemy_sprites + @actor_sprites
  119.     sprite.update
  120.   end
  121.   # 刷新天气图形
  122.   @weather.type = $game_screen.weather_type
  123.   @weather.max = $game_screen.weather_max
  124.   @weather.update
  125.   # 刷新图片精灵光标
  126.   for sprite in @picture_sprites
  127.     sprite.update
  128.   end
  129.   # 刷新计时器精灵光标
  130.   @timer_sprite.update
  131.   # 设置画面的色调与震动位置
  132.    @viewport1.tone = $game_screen.tone
  133.    @viewport1.ox = (-1) ** rand(2) * $game_screen.shake
  134.    @viewport1.oy = (-1) ** rand(2) * $game_screen.shake
  135.   #让图片也可以震动
  136.   @viewport2.tone = $game_screen.tone
  137.   @viewport2.ox = (-1) ** rand(2) * $game_screen.shake
  138.   @viewport2.oy = (-1) ** rand(2) * $game_screen.shake
  139.   # 设置画面的闪烁色
  140.   #@viewport4.color = $game_screen.flash_color
  141.   # 刷新视图
  142.   @viewport1.update
  143.   @viewport2.update
  144.   #@viewport4.update
  145. end
  146. end
复制代码


地震时全图片动态,导致图片遮盖效果不理想
图片最多可以设置50张,这个脚本有没有办法弄成"图片"震动只对30~50号图片有效?
作者: 紫苏    时间: 2009-6-3 17:23
这个脚本是通过改变显示图片用的 viewport 的坐标来实现震动效果的,所以所有在这个 viewport 中显示的图片都会同步震动(相对静止)……
如果要让部分图片不震动的话,只能把那一部分图片单独放到另一个 viewport 中,这样就不会震动到新的这个 viewport 了~
class Spriteset_Map
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    # 生成显示端口
    @viewport1 = Viewport.new(0, 0, 640, 480)
    @viewport2 = Viewport.new(0, 0, 640, 480)
    @viewport3 = Viewport.new(0, 0, 640, 480)
    @viewport4 = Viewport.new(0, 0, 640, 480)
    @viewport2.z = 200
    @viewport3.z = 5000
    @viewport4.z = 200
    # 生成元件地图
    @tilemap = Tilemap.new(@viewport1)
    @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
    for i in 0..6
      autotile_name = $game_map.autotile_names
      @tilemap.autotiles = RPG::Cache.autotile(autotile_name)
    end
    @tilemap.map_data = $game_map.data
    @tilemap.priorities = $game_map.priorities
    # 生成远景平面
    @panorama = Plane.new(@viewport1)
    @panorama.z = -1000
    # 生成雾平面
    @fog = Plane.new(@viewport1)
    @fog.z = 3000
    # 生成角色活动块
    @character_sprites = []
    for i in $game_map.events.keys.sort
      sprite = Sprite_Character.new(@viewport1, $game_map.events)
      @character_sprites.push(sprite)
    end
    @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
    # 生成天气
    @weather = RPG::Weather.new(@viewport1)
    # 生成图片
    @picture_sprites = []
    for i in 30..50
      @picture_sprites.push(Sprite_Picture.new(@viewport2,
        $game_screen.pictures))
    end
    for i in 1..29
      @picture_sprites.push(Sprite_Picture.new(@viewport4,
        $game_screen.pictures))
    end

    # 生成计时器块
    @timer_sprite = Sprite_Timer.new
    # 刷新画面
    update
  end
  alias dispose_old dispose unless method_defined? :dispose_old
  def dispose
    dispose_old
    @viewport4.dispose
  end
end

作者: jhhuang    时间: 2009-6-3 19:10
alias dispose_old dispose unless method_defined? :dispose_old
这是什么?会出错
作者: jhhuang    时间: 2009-6-3 19:28
太乱了....郁闷了,这个脚本的修改还是放弃算了




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1