Jump to content
Rpg²S Forum

*Sfondo a schermo intero nelle battaglie


Tio
 Share

Recommended Posts

Sfondo a schermo intero nelle battaglie

Descrizione

Lo script permette di ingrandire lo sfondo (battleback) e di fargli occupare tutto lo schermo.. molto utile per i bs personalizzati in cui le finestre di stato dei personagi occupano posizioni diverse o sono trasparenti/invisibili.

Autore

Sconosciuto (giapponese)

Allegati
Screen (il bs non c'entra nulla con lo script, è solo per far vedere come funziona lo script)
http://img471.imageshack.us/img471/9388/tpcbattle1jt6.th.jpg

Istruzioni per l'uso

Basta creare una nuova classe sopra Main e inserirci il codice che trovate qua sotto. Lo script potrebbe dare problemi a chi ha inserito elementi grafici in più dinamici nella schermata di battaglia (come immagini per i comandi di battaglia e roba simile).

 

#========================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors)
# の内部で使用され、Game_Party クラス ($game_party) からも参照されます。
#======================================================

class Game_Actor < Game_Battler
    
    #--------------------------------------------------------------------------
    # ● バトル画面 X 座標の取得
    #--------------------------------------------------------------------------
    
    def screen_x
        # パーティ内の並び順から X 座標を計算して返す
        if self.index != nil
            return self.index * 50 + (4 - $game_party.actors.size) * 30 + 450 #prima era * 80 + 80
        else
            return 0
        end
    end
    def screen_y
        # パーティ内の並び順から X 座標を計算して返す
        if self.index != nil
            return self.index * 70 + (4 - $game_party.actors.size) + 230 #prima era * 80 + 80
        else
            return 0
        end
    end
end



#======================================================
# ■ Spriteset_Battle
#------------------------------------------------------------------------------
#  バトル画面のスプライトをまとめたクラスです。このクラスは Scene_Battle クラ
# スの内部で使用されます。
#=====================================================
class Spriteset_Battle
    #--------------------------------------------------------------------------
    # ● オブジェクト初期化
    #--------------------------------------------------------------------------
    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 = 101
        @viewport3.z = 200
        @viewport4.z = 99999
        
        # バトルバックスプライトを作成
        
        @battleback_sprite = Sprite.new(@viewport1)
        
        # エネミースプライトを作成
        
        @enemy_sprites = []
        for enemy in $game_troop.enemies.reverse
            @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
        end
        
        # アクタースプライトを作成
        
        @actor_sprites = []
        @actor_sprites.push(Sprite_Battler.new(@viewport2))
        @actor_sprites.push(Sprite_Battler.new(@viewport2))
        @actor_sprites.push(Sprite_Battler.new(@viewport2))
        @actor_sprites.push(Sprite_Battler.new(@viewport2))
        
        # 天候を作成
        
        @weather = RPG::Weather.new(@viewport1)
        # ピクチャスプライトを作成
        
        @picture_sprites = []
        for i in 51..100
            @picture_sprites.push(Sprite_Picture.new(@viewport3,
            $game_screen.pictures[i]))
        end
        # タイマースプライトを作成
        @timer_sprite = Sprite_Timer.new
        # フレーム更新
        
        update
        
    end
    
    #--------------------------------------------------------------------------
    # ● フレーム更新
    #--------------------------------------------------------------------------
    
    def update
        
        # アクタースプライトの内容を更新 (アクターの入れ替えに対応)
        @actor_sprites[0].battler = $game_party.actors[0]
        @actor_sprites[1].battler = $game_party.actors[1]
        @actor_sprites[2].battler = $game_party.actors[2]
        @actor_sprites[3].battler = $game_party.actors[3]
        
        # バトルバックのファイル名が現在のものと違う場合
        if @battleback_name != $game_temp.battleback_name
            @battleback_name = $game_temp.battleback_name
            if @battleback_sprite.bitmap != nil
                @battleback_sprite.bitmap.dispose
            end
            @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
            @battleback_sprite.src_rect.set(0, 0, 640, 480)
            if @battleback_sprite.bitmap.height == 320
                @battleback_sprite.src_rect.set(0, 0, 640, 480)
                @battleback_sprite.zoom_x = 1.5
                @battleback_sprite.zoom_y = 1.5
                @battleback_sprite.x = 320
                @battleback_sprite.y = 240
                @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
                @battleback_sprite.oy = @battleback_sprite.bitmap.height / 2
            end
        end
        
        # バトラースプライトを更新
        
        for sprite in @enemy_sprites + @actor_sprites
            sprite.update
        end
        
        # 天候グラフィックを更新
        
        @weather.type = $game_screen.weather_type
        @weather.max = $game_screen.weather_max
        @weather.update
        
        # ピクチャスプライトを更新
        
        for sprite in @picture_sprites
            sprite.update
        end
        
        # タイマースプライトを更新
        
        @timer_sprite.update
        
        # 画面の色調とシェイク位置を設定
        
        @viewport1.tone = $game_screen.tone
        @viewport1.ox = $game_screen.shake
        
        # 画面のフラッシュ色を設定
        
        @viewport4.color = $game_screen.flash_color
        # ビューポートを更新
        @viewport1.update
        @viewport2.update
        @viewport4.update
    end
    
end







#====================================================
# ■ Scene_Battle (分割定義 3)
#------------------------------------------------------------------------------
#  バトル画面の処理を行うクラスです。
#====================================================

class Scene_Battle
    
    #--------------------------------------------------------------------------
    # ● アクターコマンドウィンドウのセットアップ
    #--------------------------------------------------------------------------
    
    def phase3_setup_command_window
        
        # パーティコマンドウィンドウを無効化
        
        @party_command_window.active = false
        @party_command_window.visible = false
        # アクターコマンドウィンドウを有効化
        @actor_command_window.active = true
        @actor_command_window.visible = true
        # アクターコマンドウィンドウの位置を設定
        @actor_command_window.width = 115
        @actor_command_window.x = 0
        @actor_command_window.y = 0
        # インデックスを 0 に設定
        @actor_command_window.index = 0
        @status_window.opacity = 0
        @status_window.x = 100
        @status_window.y = 0
        $icona[i].opacity = 255
    end
    
end



#===================================================
# ■ Spriteモジュール
#------------------------------------------------------------------------------
#  アニメーションの管理を行うモジュールです。
#==================================================

module RPG
    
    class Sprite < ::Sprite
        def animation_set_sprites(sprites, cell_data, position)
            for i in 0..15
                sprite = sprites[i]
                pattern = cell_data[i, 0]
                if sprite == nil or pattern == nil or pattern == -1
                    sprite.visible = false if sprite != nil
                    next
                end
                sprite.visible = true
                sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
                if position == 3
                    if self.viewport != nil
                        sprite.x = self.viewport.rect.width / 2
                        if self.battler.is_a?(Game_Actor)
                            sprite.y = self.viewport.rect.height - 160
                        else
                            sprite.y = self.viewport.rect.height - 320
                        end
                    else
                        sprite.x = 320
                        sprite.y = 240
                    end
                else
                    sprite.x = self.x + self.viewport.rect.x - self.ox + self.src_rect.width / 2
                    sprite.y = self.y + self.viewport.rect.y - self.oy * self.zoom_y + self.src_rect.height * self.zoom_y  / 2
                    sprite.y -= self.src_rect.height / 4 if position == 0
                    sprite.y += self.src_rect.height / 4 if position == 2
                end
                sprite.x += cell_data[i, 1]
                sprite.y += cell_data[i, 2]
                sprite.z = 2000
                sprite.ox = 96
                sprite.oy = 96
                sprite.zoom_x = cell_data[i, 3] / 100.0
                sprite.zoom_y = cell_data[i, 3] / 100.0
                sprite.angle = cell_data[i, 4]
                sprite.mirror = (cell_data[i, 5] == 1)
                sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
                sprite.blend_type = cell_data[i, 7]
            end
        end
    end
end

 

 

"Dopo gli ultimi Final Fantasy, ho capito solamente una cosa: che il gioco è bello quando Nomura poco."

Making is not dead. You are dead.
RELEASE: La Bussola d'Oro | Download | Video di anteprima - La Partenza di Hanna

http://i.imgur.com/cFgc2lW.png

Prova Standrama!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...