Sujet n°6932
Posté par Mack le 30 Mai - 10:38 (2010)
Titre : Découpage d'un sprite -> Utilisation d'une planche
Voila, toujours dans mon optique d'améliorer mon jeu sur PSP DS, je voudrait modifier un peu le CBS. J'ai réussis
 à faire comme je voulais jusque là, sauf que j'aimerais animé les sprites en suivant une planche comme celle là :
   
La planche est donc diviser en trois ligne : La première, la ligne d'attente, la seconde, la ligne d'attaque, et la troisième, 
la ligne de dégat, bien sur, chaque ligne est animé en boucle. ( D'ailleurs, c'est possible de faire qu'elle soit pas animé 
en boucle, mais qu'une fois la ligne finit elle reste sur la première pose ? ) 
Spoiler
On m'a proposé :

Code:

        @interface = Sprite.new       
@interface.bitmap = RPG::Cache.picture("Planche2")        
@interface.bitmap.stretch_blt(Rect.new(0,80,40,40),    @interface.bitmap,  Rect.new(0,0,40,40))#1     
@interface.x = 13     
@interface.y = 227    
 @interface.z = 10000





















Mais il me garde la planche dessous, avec la superposition sur un autre endroits, le problème, c'est que apparament, 
si je change trop le 80, il sort de ce rectangle, et du coup, il m'affiche pas le découpage en entier. Un ami m'a proposé d'utiliser ça :
Code:
$var.bitmap.stretch_blt(rect de collage, chara de copie, rect de copie)#1





















Mais je comprend pas comment m'en servir ... ( Il est partit et ne peut plus m'aider donc ^^" )

Pour prendre une autre pose, c'est bien les chiffre 0,0 de
Code:
@interface.bitmap,  Rect.new(0,0,40,40))#1





















que je doit changer ? ( Ca à l'air d'être ça, mais sait on jamais ^^ ) ( Je ne demande pas de me le mettre tout près 
dans le combat, mais juste comment faire le décapge, et comment m'en servir ) 
Donc, c'est pas spécialment sur PSP DS, mais comme je bosse dessu pour l'instant ^^" 
Merci d'avance

Spoiler
On m'a aussi proposé d'utiliser :
 
Code:
index_width = 1 # Index de la frame en largeur
index_height = 2 # Index de la frame en longueur
@interface  = Sprite.new  
@interface.bitmap = RPG::Cache.picture("Planche2")   
fw = @interface.bitmap.width / 4 # 4 correspond au nombre de frame en largeur sur ton image
fh = @interface.bitmap.height / 3 # Pareil mais en longueur
xw = fw*index_width
yh = fh*index_height
@interface.src_rect.set(xw, yh, fw, fh)
@interface.x = 13
@interface.y = 227
@interface.z = 10000 









Jusque là tout marche, j'essaie ensuite de faire l'animation :
Je créais donc une variable :
@animation_count
Et je fais comme a :
 
Code:
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
#  メニュー画面の処理を行うクラスです。
#==============================================================================


class Scene_Menu
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     menu_index : コマンドのカーソル初期位置
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # ● メイン処理
  #--------------------------------------------------------------------------
  def main
    # コマンドウィンドウを作成
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Status"
    s5 = "Save"
    s6 = "End Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
    @command_window.index = @menu_index
    # パーティ人数が 0 人の場合
    if $game_party.actors.size == 0
      # アイテム、スキル、装備、ステータスを無効化
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
index_width = 1 # Index de la frame en largeur
index_height = 2 # Index de la frame en longueur
@interface  = Sprite.new  
@interface.bitmap = RPG::Cache.picture("Planche2")   
fw = @interface.bitmap.width / 3 # 3 correspond au nombre de frame en largeur sur ton image
fh = @interface.bitmap.height / 3 # Pareil mais en longueur
xw = 0#fw*index_width  # C'est pour choisir la partie du sprite que je prendrais Ici la longueur
yh = 40#fh*index_height  # C'est pour choisir la partie du sprite que je prendrais Ici la Hauteur.
@interface.src_rect.set(xw, yh, fw, fh)
@interface.x = 13
@interface.y = 227
@interface.zoom_x = 0.5
@interface.zoom_y = 0.5
@interface.z = 10000
    @animation_count = 0


    # セーブ禁止の場合
    if $game_system.save_disabled
      # セーブを無効にする
      @command_window.disable_item(4)
    end
    # プレイ時間ウィンドウを作成
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 0
    @playtime_window.y = 224
    # 歩数ウィンドウを作成
    @steps_window = Window_Steps.new
    @steps_window.x = 0
    @steps_window.y = 320
    # ゴールドウィンドウを作成
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = 416
    # ステータスウィンドウを作成
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0
    # トランジション実行
    Graphics.transition
    # メインループ
loop do
@animation_count +=1
  
  if @animation_count == 3
xw = 40#fw*index_width  # C'est pour choisir la partie du sprite que je prendrais Ici la longueur
yh = 40#fh*index_height  # C'est pour choisir la partie du sprite que je prendrais Ici la Hauteur
    end
  end
    loop do
      # ゲーム画面を更新
      Graphics.update
      # 入力情報を更新
      Input.update
      # フレーム更新
      update
      # 画面が切り替わったらループを中断
      if $scene != self
        break
      end
    end
    # トランジション準備
    Graphics.freeze
    # ウィンドウを解放
    @command_window.dispose
    @playtime_window.dispose
    @steps_window.dispose
    @gold_window.dispose
    @status_window.dispose
       @interface.dispose
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    # ウィンドウを更新
    @command_window.update
    @playtime_window.update
    @steps_window.update
    @gold_window.update
    @status_window.update
    @interface.update
    # コマンドウィンドウがアクティブの場合: update_command を呼ぶ
    if @command_window.active
      update_command
      return
    end
    # ステータスウィンドウがアクティブの場合: update_status を呼ぶ
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (コマンドウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  def update_command
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # マップ画面に切り替え
      $scene = Scene_Map.new
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # パーティ人数が 0 人で、セーブ、ゲーム終了以外のコマンドの場合
      if $game_party.actors.size == 0 and @command_window.index < 4
        # ブザー SE を演奏
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # コマンドウィンドウのカーソル位置で分岐
      case @command_window.index
      when 0  # アイテム
        # 決定  SE を演奏
        $game_system.se_play($data_system.decision_se)
        # アイテム画面に切り替え
        $scene = Scene_Item.new
      when 1  # スキル
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # ステータスウィンドウをアクティブにする
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2  # 装備
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # ステータスウィンドウをアクティブにする
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3  # ステータス
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # ステータスウィンドウをアクティブにする
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 4  # セーブ
        # セーブ禁止の場合
        if $game_system.save_disabled
          # ブザー SE を演奏
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # セーブ画面に切り替え
        $scene = Scene_Save.new
      when 5  # ゲーム終了
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # ゲーム終了画面に切り替え
        $scene = Scene_End.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (ステータスウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  def update_status
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # コマンドウィンドウをアクティブにする
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # コマンドウィンドウのカーソル位置で分岐
      case @command_window.index
      when 1  # スキル
        # このアクターの行動制限が 2 以上の場合
        if $game_party.actors[@status_window.index].restriction >= 2
          # ブザー SE を演奏
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # スキル画面に切り替え
        $scene = Scene_Skill.new(@status_window.index)
      when 2  # 装備
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # 装備画面に切り替え
        $scene = Scene_Equip.new(@status_window.index)
      when 3  # ステータス
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # ステータス画面に切り替え
        $scene = Scene_Status.new(@status_window.index)
      end
      return
    end
  end
end

 









Mais le jeu plante au démarage avec que des points d'intérrogation ...





Je pense qu'il va falloir utiliser ça :
      

 
Code:
index_width = 0
index_height = 1
@enemy  = Sprite.new  
@enemy_sprite.bitmap = RPG::Cache.battler(@enemy.battler_face, 0)
@fw = @enemy.bitmap.width / 3
@fh = @enemy.bitmap.height / 3
xw = @fw*index_width
yh = @fh*index_height
@enemy.src_rect.set(xw, yh, @fw, @fh)
 





Mais je trouve pas où le mettre ...
Quand je le met dans Battle_Core 1 avant :
 
Code:
   @enemy_sprite = RPG::Sprite.new(battle_viewport)
      @enemy_sprite.x = 324 #464
      @enemy_sprite.y = 105#95
      @enemy_sprite.z = @z_level + 15
 





Le jeu plante ...

 
Citation:
---------- Erreur de script : Pokemon_Battle_Core 1* ----------
----- Type
NoMethodError


----- Message
- ARGS - []
undefined method `battler_face' for #<Sprite:0xb49dff0>


----- Position dans Pokemon_Battle_Core 1*
Ligne 199


----- Backtrace
Script : Pokemon_Battle_Core 1* | Ligne : 199 | Méthode : in `main'
Script : Main | Ligne : 60












J'me disait qu'il fallait peut être le mettre dans le script Pokemon, à la ligne où il gère les battler ?
Mais :

 
Citation:
---------- Erreur de script : Pokemon_Battle_Core 1* ----------
----- Type
NoMethodError


----- Message
- ARGS - []
undefined method `width' for nil:NilClass


----- Position dans Pokemon_Battle_Core 1*
Ligne 201


----- Backtrace
Script : Pokemon_Battle_Core 1* | Ligne : 201 | Méthode : in `main'
Script : Main | Ligne : 60












Donc je demande pas comment faire l'animation, ça c'est bon, c'est juste pour découper la planche, car soit ça le fait pas, soit le jeu plante ...