Project1

标题: 请问如何修改这个脚本的人物位置? [打印本页]

作者: xkm198510    时间: 2015-4-7 14:08
标题: 请问如何修改这个脚本的人物位置?
见下面脚本

RUBY 代码复制
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Spriteset_Battle
  4. #------------------------------------------------------------------------------
  5. #  處理戰斗畫面的精靈的類。本類在 Scene_Battle 類的內部使用。
  6. #==============================================================================
  7.  
  8. class Spriteset_Battle
  9.   #--------------------------------------------------------------------------
  10.   # ● 初始化對象
  11.   #--------------------------------------------------------------------------
  12.   def initialize
  13.     create_viewports
  14.     create_battleback1
  15.     create_battleback2
  16.     create_enemies
  17.     create_actors
  18.     create_pictures
  19.     create_timer
  20.     update
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 生成顯示端口
  24.   #--------------------------------------------------------------------------
  25.   def create_viewports
  26.     @viewport1 = Viewport.new
  27.     @viewport2 = Viewport.new
  28.     @viewport3 = Viewport.new
  29.     @viewport2.z = 50
  30.     @viewport3.z = 100
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # ● 生成戰場背景(地面)精靈
  34.   #--------------------------------------------------------------------------
  35.   def create_battleback1
  36.     @back1_sprite = Sprite.new(@viewport1)
  37.     @back1_sprite.bitmap = battleback1_bitmap
  38.     @back1_sprite.z = 0
  39.     center_sprite(@back1_sprite)
  40.   end
  41.   #--------------------------------------------------------------------------
  42.   # ● 生成戰場背景(墻壁)精靈
  43.   #--------------------------------------------------------------------------
  44.   def create_battleback2
  45.     @back2_sprite = Sprite.new(@viewport1)
  46.     @back2_sprite.bitmap = battleback2_bitmap
  47.     @back2_sprite.z = 1
  48.     center_sprite(@back2_sprite)
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ● 獲取戰場背景(地面)的位圖
  52.   #--------------------------------------------------------------------------
  53.   def battleback1_bitmap
  54.     if battleback1_name
  55.       Cache.battleback1(battleback1_name)
  56.     else
  57.       create_blurry_background_bitmap
  58.     end
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ● 獲取戰場背景(墻壁)的位圖
  62.   #--------------------------------------------------------------------------
  63.   def battleback2_bitmap
  64.     if battleback2_name
  65.       Cache.battleback2(battleback2_name)
  66.     else
  67.       Bitmap.new(1, 1)
  68.     end
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● 生成由地圖畫面加工而來的戰場背景
  72.   #--------------------------------------------------------------------------
  73.   def create_blurry_background_bitmap
  74.     source = SceneManager.background_bitmap
  75.     bitmap = Bitmap.new(640, 480)
  76.     bitmap.stretch_blt(bitmap.rect, source, source.rect)
  77.     bitmap.radial_blur(120, 16)
  78.     bitmap
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ● 獲取戰場背景(地面)的文件名
  82.   #--------------------------------------------------------------------------
  83.   def battleback1_name
  84.     if $BTEST
  85.       $data_system.battleback1_name
  86.     elsif $game_map.battleback1_name
  87.       $game_map.battleback1_name
  88.     elsif $game_map.overworld?
  89.       overworld_battleback1_name
  90.     end
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 獲取戰場背景(墻壁)的文件名
  94.   #--------------------------------------------------------------------------
  95.   def battleback2_name
  96.     if $BTEST
  97.       $data_system.battleback2_name
  98.     elsif $game_map.battleback2_name
  99.       $game_map.battleback2_name
  100.     elsif $game_map.overworld?
  101.       overworld_battleback2_name
  102.     end
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # ● 獲取戰場背景(地面)文件名
  106.   #--------------------------------------------------------------------------
  107.   def overworld_battleback1_name
  108.     $game_player.vehicle ? ship_battleback1_name : normal_battleback1_name
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● 獲取戰場背景(墻壁)文件名
  112.   #--------------------------------------------------------------------------
  113.   def overworld_battleback2_name
  114.     $game_player.vehicle ? ship_battleback2_name : normal_battleback2_name
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # ● 獲取普通時的戰場背景(地面)文件名
  118.   #--------------------------------------------------------------------------
  119.   def normal_battleback1_name
  120.     terrain_battleback1_name(autotile_type(1)) ||
  121.     terrain_battleback1_name(autotile_type(0)) ||
  122.     default_battleback1_name
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● 獲取普通時的戰場背景(墻壁)文件名
  126.   #--------------------------------------------------------------------------
  127.   def normal_battleback2_name
  128.     terrain_battleback2_name(autotile_type(1)) ||
  129.     terrain_battleback2_name(autotile_type(0)) ||
  130.     default_battleback2_name
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # ● 獲取與地形對應的戰場背景(地面)文件名
  134.   #--------------------------------------------------------------------------
  135.   def terrain_battleback1_name(type)
  136.     case type
  137.     when 24,25        # 野外
  138.       "Wasteland"
  139.     when 26,27        # 泥地
  140.       "DirtField"
  141.     when 32,33        # 沙漠
  142.       "Desert"
  143.     when 34           # 巖地
  144.       "Lava1"
  145.     when 35           # 巖地(熔巖)
  146.       "Lava2"
  147.     when 40,41        # 雪原
  148.       "Snowfield"
  149.     when 42           # 云端
  150.       "Clouds"
  151.     when 4,5          # 毒沼
  152.       "PoisonSwamp"
  153.     end
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # ● 獲取與地形對應的戰場背景(墻壁)文件名
  157.   #--------------------------------------------------------------------------
  158.   def terrain_battleback2_name(type)
  159.     case type
  160.     when 20,21        # 森林
  161.       "Forest1"
  162.     when 22,30,38     # 山丘
  163.       "Cliff"
  164.     when 24,25,26,27  # 野外、泥地
  165.       "Wasteland"
  166.     when 32,33        # 沙漠
  167.       "Desert"
  168.     when 34,35        # 巖地
  169.       "Lava"
  170.     when 40,41        # 雪原
  171.       "Snowfield"
  172.     when 42           # 云端
  173.       "Clouds"
  174.     when 4,5          # 毒沼
  175.       "PoisonSwamp"
  176.     end
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 獲取默認的戰場背景(地面)文件名
  180.   #--------------------------------------------------------------------------
  181.   def default_battleback1_name
  182.     "Grassland"
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ● 獲取默認的戰場背景(墻壁)文件名
  186.   #--------------------------------------------------------------------------
  187.   def default_battleback2_name
  188.     "Grassland"
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # ● 獲取乘船時的戰場背景(地面)文件名
  192.   #--------------------------------------------------------------------------
  193.   def ship_battleback1_name
  194.     "Ship"
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # ● 獲取乘船時的戰場背景(墻壁)文件名
  198.   #--------------------------------------------------------------------------
  199.   def ship_battleback2_name
  200.     "Ship"
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ● 獲取角色腳下的自動原件的種類
  204.   #--------------------------------------------------------------------------
  205.   def autotile_type(z)
  206.     $game_map.autotile_type($game_player.x, $game_player.y, z)
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   # ● 精靈居中
  210.   #--------------------------------------------------------------------------
  211.   def center_sprite(sprite)
  212.     sprite.ox = sprite.bitmap.width / 2
  213.     sprite.oy = sprite.bitmap.height / 2
  214.     sprite.x = Graphics.width / 2
  215.     sprite.y = Graphics.height / 2
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ● 敵人精靈生成
  219.   #--------------------------------------------------------------------------
  220.   def create_enemies
  221.     @enemy_sprites = $game_troop.members.reverse.collect do |enemy|
  222.       Sprite_Battler.new(@viewport1, enemy)
  223.     end
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● 生成角色精靈
  227.   #    默認下不顯示角色的圖像。為了方便使用,敵我雙方使用共通的精靈。
  228.   #--------------------------------------------------------------------------
  229.   def create_actors
  230.     @actor_sprites = Array.new(4) { Sprite_Battler.new(@viewport1) }
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ● 生成圖片精靈
  234.   #    游戲開始時生成空的數組,在需要使用時才添加內容。
  235.   #--------------------------------------------------------------------------
  236.   def create_pictures
  237.     @picture_sprites = []
  238.   end
  239.   #--------------------------------------------------------------------------
  240.   # ● 計時器精靈生成
  241.   #--------------------------------------------------------------------------
  242.   def create_timer
  243.     @timer_sprite = Sprite_Timer.new(@viewport2)
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # ● 釋放
  247.   #--------------------------------------------------------------------------
  248.   def dispose
  249.     dispose_battleback1
  250.     dispose_battleback2
  251.     dispose_enemies
  252.     dispose_actors
  253.     dispose_pictures
  254.     dispose_timer
  255.     dispose_viewports
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ● 釋放戰場背景的精靈(地面)
  259.   #--------------------------------------------------------------------------
  260.   def dispose_battleback1
  261.     @back1_sprite.bitmap.dispose
  262.     @back1_sprite.dispose
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   # ● 釋放戰場背景的精靈(墻壁)
  266.   #--------------------------------------------------------------------------
  267.   def dispose_battleback2
  268.     @back2_sprite.bitmap.dispose
  269.     @back2_sprite.dispose
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● 釋放敵人精靈
  273.   #--------------------------------------------------------------------------
  274.   def dispose_enemies
  275.     @enemy_sprites.each {|sprite| sprite.dispose }
  276.   end
  277.   #--------------------------------------------------------------------------
  278.   # ● 釋放角色精靈
  279.   #--------------------------------------------------------------------------
  280.   def dispose_actors
  281.     @actor_sprites.each {|sprite| sprite.dispose }
  282.   end
  283.   #--------------------------------------------------------------------------
  284.   # ● 釋放圖片精靈
  285.   #--------------------------------------------------------------------------
  286.   def dispose_pictures
  287.     @picture_sprites.compact.each {|sprite| sprite.dispose }
  288.   end
  289.   #--------------------------------------------------------------------------
  290.   # ● 釋放計時器精靈
  291.   #--------------------------------------------------------------------------
  292.   def dispose_timer
  293.     @timer_sprite.dispose
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # ● 釋放顯示端口
  297.   #--------------------------------------------------------------------------
  298.   def dispose_viewports
  299.     @viewport1.dispose
  300.     @viewport2.dispose
  301.     @viewport3.dispose
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # ● 更新畫面
  305.   #--------------------------------------------------------------------------
  306.   def update
  307.     update_battleback1
  308.     update_battleback2
  309.     update_enemies
  310.     update_actors
  311.     update_pictures
  312.     update_timer
  313.     update_viewports
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● 更新戰場背景的精靈(地面)
  317.   #--------------------------------------------------------------------------
  318.   def update_battleback1
  319.     @back1_sprite.update
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # ● 更新戰場背景的精靈(墻壁)
  323.   #--------------------------------------------------------------------------
  324.   def update_battleback2
  325.     @back2_sprite.update
  326.   end
  327.   #--------------------------------------------------------------------------
  328.   # ● 更新敵人的精靈
  329.   #--------------------------------------------------------------------------
  330.   def update_enemies
  331.     @enemy_sprites.each {|sprite| sprite.update }
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # ● 更新角色的精靈
  335.   #--------------------------------------------------------------------------
  336.   def update_actors
  337.     @actor_sprites.each_with_index do |sprite, i|
  338.       sprite.battler = $game_party.members[i]
  339.       sprite.update
  340.     end
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● 更新圖片精靈
  344.   #--------------------------------------------------------------------------
  345.   def update_pictures
  346.     $game_troop.screen.pictures.each do |pic|
  347.       @picture_sprites[pic.number] ||= Sprite_Picture.new(@viewport2, pic)
  348.       @picture_sprites[pic.number].update
  349.     end
  350.   end
  351.   #--------------------------------------------------------------------------
  352.   # ● 更新計時器精靈
  353.   #--------------------------------------------------------------------------
  354.   def update_timer
  355.     @timer_sprite.update
  356.   end
  357.   #--------------------------------------------------------------------------
  358.   # ● 更新顯示端口
  359.   #--------------------------------------------------------------------------
  360.   def update_viewports
  361.     @viewport1.tone.set($game_troop.screen.tone)
  362.     @viewport1.ox = $game_troop.screen.shake
  363.     @viewport2.color.set($game_troop.screen.flash_color)
  364.     @viewport3.color.set(0, 0, 0, 255 - $game_troop.screen.brightness)
  365.     @viewport1.update
  366.     @viewport2.update
  367.     @viewport3.update
  368.   end
  369.   #--------------------------------------------------------------------------
  370.   # ● 獲取敵人和角色的精靈
  371.   #--------------------------------------------------------------------------
  372.   def battler_sprites
  373.     @enemy_sprites + @actor_sprites
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # ● 判定是否動畫顯示中
  377.   #--------------------------------------------------------------------------
  378.   def animation?
  379.     battler_sprites.any? {|sprite| sprite.animation? }
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # ● 判定效果是否執行中
  383.   #--------------------------------------------------------------------------
  384.   def effect?
  385.     battler_sprites.any? {|sprite| sprite.effect? }
  386.   end
  387. end





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