질문과 답변

Extra Form
 




#==============================================================================
# +++ MOG - Scene Character Select V1.0 +++
#==============================================================================
# By Moghunter
# http://www.atelier-rgss.com/
#==============================================================================
# Tela de seleção de personagens.
#==============================================================================
# 1 - Deverão conter as seguintes imagens na pasta GRAPHICS/SYSTEM.
#
# Background
# Char_Layout01
# Char_Layout02
# Char_Status_Layout
# Number_Char
#
# 2 - Imagem de pose. (Opcional)
# Para ativar a imagem de pose dos personagens, basta ter os arquivos de pose
# gravados na pasta (GRAPHICS/PICTURES)
# Você deverá nomear as imagens da seguinte forma.
#
# Character + ID_DO_PERSONAGEM
#
# Exemplo:
#
# Character1.png
#
#==============================================================================
# Para chamar o script use o seguinte comando.
#
# SceneManager.call(Scene_Character_Select)
#
#==============================================================================


#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
 
  #--------------------------------------------------------------------------
  # ● draw_picture_number(x,y,value,file_name,align, space, frame_max ,frame_index)    
  #--------------------------------------------------------------------------
  # X - Posição na horizontal
  # Y - Posição na vertical
  # VALUE - Valor Numérico
  # FILE_NAME - Nome do arquivo
  # ALIGN - Centralizar 0 - Esquerda 1- Centro 2 - Direita 
  # SPACE - Espaço entre os números.
  # FRAME_MAX - Quantidade de quadros(Linhas) que a imagem vai ter.
  # FRAME_INDEX - Definição do quadro a ser utilizado.
  #-------------------------------------------------------------------------- 
  def draw_picture_number(x,y,value, file_name,align = 0, space = 0, frame_max = 1,frame_index = 0)    
      number_image = Cache.system(file_name)
      frame_max = 1 if frame_max < 1
      frame_index = frame_max -1 if frame_index > frame_max -1
      align = 2 if align > 2
      cw = number_image.width / 10
      ch = number_image.height / frame_max
      h = ch * frame_index
      number = value.abs.to_s.split(//)
      case align
          when 0
             plus_x = (-cw + space) * number.size
          when 1
             plus_x = (-cw + space) * number.size
             plus_x /= 2
          when 2 
             plus_x = 0
      end
      for r in 0..number.size - 1      
          number_abs = number[r].to_i
          number_rect = Rect.new(cw * number_abs, h, cw, ch)
          self.contents.blt(plus_x + x + ((cw - space) * r), y , number_image, number_rect)       
      end
      number_image.dispose 
   end
  #--------------------------------------------------------------------------
  # ● draw_char_window_status 
  #-------------------------------------------------------------------------- 
  def draw_char_window_status(x,y)
      image = Cache.system("Char_Status_Layout")   
      cw = image.width 
      ch = image.height
      src_rect = Rect.new(0, 0, cw, ch)   
      self.contents.blt(x , y , image, src_rect)
      image.dispose
  end    
end 

#===============================================================================
# ■ RPG_FileTest
#===============================================================================
module RPG_FileTest
 
  #--------------------------------------------------------------------------
  # ● RPG_FileTest.system_exist?
  #--------------------------------------------------------------------------
  def RPG_FileTest.system_exist?(filename)
      return Cache.system(filename) rescue return false
  end 
 
  #--------------------------------------------------------------------------
  # ● RPG_FileTest.picture_exist?
  #--------------------------------------------------------------------------
  def RPG_FileTest.picture_exist?(filename)
      return Cache.picture(filename) rescue return false
  end  
 
end

#==============================================================================
# ** Window_Character_Status
#==============================================================================
class Window_Character_Status < Window_Base
  attr_accessor :index
  #--------------------------------------------------------------------------
  # ● initialize
  #--------------------------------------------------------------------------
  def initialize(actor)
      super(0, 0, 400, 130)
      self.opacity = 0
      actor_id = []
      @index = actor
      for i in 1...$data_actors.size
        actor_id.push($game_actors[i])
      end
      @actor = actor_id[actor -1]
      refresh
  end
  #--------------------------------------------------------------------------
  # ● Refresh
  #--------------------------------------------------------------------------
  def refresh
      self.contents.clear
      self.contents.font.bold = true
      self.contents.font.italic = true
      draw_char_window_status(0, 6)   
      draw_actor_face(@actor, 0, 0)
      draw_actor_name(@actor, 140, -5)
      draw_actor_class(@actor, 60, 70)   
      draw_picture_number(155,20,@actor.mhp, "Number_char",1)  
      draw_picture_number(145,48,@actor.mmp, "Number_char",1)   
      draw_picture_number(228,28,@actor.atk, "Number_char",1)  
      draw_picture_number(297,28,@actor.def, "Number_char",1) 
      draw_picture_number(207,68,@actor.mat, "Number_char",1) 
      draw_picture_number(277,68,@actor.agi, "Number_char",1) 
  end
end


#==============================================================================
# ■ Scene Character Select
#==============================================================================
class Scene_Character_Select
 
 #--------------------------------------------------------------------------
 # ● Initialize
 #--------------------------------------------------------------------------
 def initialize
     setup
     create_layout
     create_window_status
     create_char_image
     reset_position(0)     
 end
  
 #--------------------------------------------------------------------------
 # ● Setup
 #--------------------------------------------------------------------------
 def setup
     @char_index = 1
     @char_max = $data_actors.size - 1
     @pw_x = 300
     @aw_x = 200    
     @nw_x = 100        
 end 
 
 #--------------------------------------------------------------------------
 # ● Main
 #--------------------------------------------------------------------------         
 def main
     Graphics.transition
     execute_loop
     execute_dispose
 end  
 
 #--------------------------------------------------------------------------
 # ● Execute Loop
 #--------------------------------------------------------------------------          
 def execute_loop
     loop do
          Graphics.update
          Input.update
          update
          if SceneManager.scene != self
              break
          end
     end
 end
 
 #--------------------------------------------------------------------------
 # ● create_background
 #--------------------------------------------------------------------------  
 def create_layout
      @background = Plane.new 
      @background.bitmap = Cache.system("Background")
      @background.z = 0
      @layout_01 = Sprite.new 
      @layout_01.bitmap = Cache.system("Char_Layout01")
      @layout_01.z = 10     
      @layout_02 = Sprite.new 
      @layout_02.bitmap = Cache.system("Char_Layout02")
      @layout_02.blend_type = 1
      @layout_02.z = 1 
  end 
 
  #--------------------------------------------------------------------------
  # ● create_window_status
  #-------------------------------------------------------------------------- 
  def create_window_status
      @window_status = []
      for i in 1...$data_actors.size
          @window_status[i] = Window_Character_Status.new(i)
          @window_status[i].z = 7
      end
      check_active_window
  end 
 
  #--------------------------------------------------------------------------
  # ● create_window_status
  #-------------------------------------------------------------------------- 
  def create_char_image   
      @actor_picture = []
      actor_id = []
      for i in 1...$data_actors.size
          actor_id.push($game_actors[i])
          actor = actor_id[i - 1]
          @actor_picture[i] = Sprite.new
          file_name = "Character" + i.to_s
          file_name = "" unless RPG_FileTest.picture_exist?(file_name)
          @actor_picture[i].bitmap = Cache.picture(file_name)
      end  
      check_active_picture
  end
  #--------------------------------------------------------------------------
  # ● check_active_window
  #--------------------------------------------------------------------------  
  def check_active_window
     for i in 1...$data_actors.size
        @pw = @char_index - 1
        @pw = 1 if @pw > @char_max
        @pw_y = 32
        @pw = @char_max if @pw < 1
        @aw = @char_index
        @aw_y = 160
        @nw = @char_index + 1
        @nw = 1 if @nw > @char_max
        @nw = @char_max if @nw < 1
        @nw_y = 288
        case @window_status[i].index
            when @pw,@aw,@nw
                 @window_status[i].visible = true
            else
                 @window_status[i].visible = false
        end
      end 
  end
   
  #--------------------------------------------------------------------------
  # ● check_active_picture 
  #--------------------------------------------------------------------------  
  def check_active_picture 
      for i in 1...$data_actors.size    
        case @window_status[i].index
            when @pw,@aw,@nw
                 @actor_picture[i].visible = true
                 @actor_picture[@pw].z = 4
                 @actor_picture[@aw].z = 6  
                 @actor_picture[@nw].z = 4     
                 @actor_picture[@pw].opacity = 120
                 @actor_picture[@aw].opacity = 255
                 @actor_picture[@nw].opacity = 120           
            else
                 @actor_picture[i].visible = false
        end    
      end
  end     
 
  #--------------------------------------------------------------------------
  # ● terminate
  #--------------------------------------------------------------------------
  def execute_dispose
      RPG::BGM.fade(2500)
      Graphics.fadeout(60)
      Graphics.wait(40)
      RPG::BGM.stop     
      for i in 1...$data_actors.size
          @window_status[i].dispose
          @actor_picture[i].bitmap.dispose
          @actor_picture[i].dispose       
      end  
      @background.bitmap.dispose
      @background.dispose
      @layout_01.bitmap.dispose   
      @layout_01.dispose
      @layout_02.bitmap.dispose   
      @layout_02.dispose   
    end
   
  #--------------------------------------------------------------------------
  # ● update
  #--------------------------------------------------------------------------
  def update
      @background.ox += 1
      update_select
      update_slide_window
      update_slide_image
  end
 
  #--------------------------------------------------------------------------
  # ● update_slide_window
  #-------------------------------------------------------------------------- 
  def update_slide_window
      @window_status[@aw].x += 1 if @window_status[@aw].x < 0
      @window_status[@nw].x -= 2 if @window_status[@nw].x > -30
      @window_status[@pw].x -= 2 if @window_status[@pw].x > -30
      slide_window_y(@pw,@pw_y)
      slide_window_y(@aw,@aw_y)
      slide_window_y(@nw,@nw_y)
  end
 
  #--------------------------------------------------------------------------
  # ● update_slide_image  
  #-------------------------------------------------------------------------- 
  def update_slide_image  
      slide_picture_x(@pw,@pw_x,15)
      slide_picture_x(@aw,@aw_x,5)
      slide_picture_x(@nw,@nw_x,15)
  end
 
  #--------------------------------------------------------------------------
  # ● slide_picture_x
  #--------------------------------------------------------------------------   
  def slide_picture_x(i,x_pos,speed)
      if @actor_picture[i].x < x_pos
         @actor_picture[i].x += speed
         @actor_picture[i].x = x_pos if @actor_picture[i].x > x_pos
      end 
      if @actor_picture[i].x > x_pos
         @actor_picture[i].x -= speed
         @actor_picture[i].x = x_pos if @actor_picture[i].x < x_pos       
       end            
  end    
 
  #--------------------------------------------------------------------------
  # ● slide_window_y
  #--------------------------------------------------------------------------   
  def slide_window_y(i,y_pos)
      if @window_status[i].y < y_pos
         @window_status[i].y += 15
         @window_status[i].y = y_pos if @window_status[i].y > y_pos
      end 
      if @window_status[i].y > y_pos
         @window_status[i].y -= 15
         @window_status[i].y = y_pos if @window_status[i].y < y_pos       
       end            
  end  
 
  #--------------------------------------------------------------------------
  # ● reset_position
  #--------------------------------------------------------------------------    
  def reset_position(diretion)
      check_active_window
      check_active_picture
      case diretion
         when 0
            @window_status[@pw].y = -64
            @actor_picture[@pw].x = 100
         when 1 
            @window_status[@nw].y = 440
            @actor_picture[@nw].x = 400
      end       
  end 
 
  #--------------------------------------------------------------------------
  # ● update_select
  #--------------------------------------------------------------------------
  def update_select
       if Input.trigger?(Input::DOWN) or Input.trigger?(Input::LEFT)
          Sound.play_cursor
          @char_index += 1
          @char_index = 1 if @char_index > @char_max
          if @char_max < 3         
             reset_position(0)
          else 
             reset_position(1)
          end  
       elsif Input.trigger?(Input::UP) or Input.trigger?(Input::RIGHT)
          Sound.play_cursor
          @char_index -= 1
          @char_index = @char_max if @char_index < 1
          reset_position(0)
       elsif Input.trigger?(Input::C)    
          Sound.play_ok
          $game_party.add_actor(@char_index)
          SceneManager.return
       end
  end
end 

$mog_rgss3_scene_character_select = true

 

 

 

 

 

 

 

이런 스크립트인데요. 실행해보면 액터에 등록해놓은 모든 캐릭터들이 주인공으로 선택이 가능합니다.

이렇게 하지말고 1번액터부터6번액터까지만 선택가능하게 한다던가 하는 방법은 없을까요?

아틀리에에서 퍼왔습니다. 근데 포르투갈어라 모르겠네요.....스크립트도 모르는데 ㅠㅠ

Comment '2'
  • profile
    습작 2012.06.06 22:49

    0.

     

      class Scene_Character_Select를 검색하신 다음 그 아래쪽으로 def setup 에서 @char_max = $data_actors.size - 1 라고 되어있는 부분을 수정하셔야 합니다.


      연재는 모든 데이터 베이스 상의 캐릭터 만큼으로 되어 있으니 원하시는 6명으로 줄이기 위해서는 @char_max = 6 으로 적어주셔야 합니다.



  • ?
    gor 2012.06.07 21:07
    감사합니다

List of Articles
종류 분류 제목 글쓴이 날짜 조회 수
공지 묻고 답하기 가이드 습작 2014.06.14 12449
RMVXA 플레이어 이벤트 편집이 되지 않네요 4 file 큰냥 2013.07.30 1355
RMVXA 플레이어 접촉 이벤트가 멋대로 실행돼요 4 레노 2018.10.25 142
RMVXA 플레이어 처음에 투명으로 어떻게 하나요? 7 포니테일 2014.02.08 801
RMVXA 플레이어 초기 위치 방향 바꾸는 법 질문.. 2 눈팅러 2015.01.25 235
RMVXA 플레이어, 동료 스킬 턴 제한 어떻게 하나요 1 신이다1 2018.05.15 118
RMVXA 플레이어가 말고 다른 물체가 접촉시 이벤트를 실행시키고싶습니다 4 file 아쳐 2016.01.05 245
RMVXA 플레이어가 설정한 이름 인식 2 Arees 2017.02.27 166
RMVXA 플레이어가 이동가능한 타일에서도 이동불가가 됩니다 4 Rocream 2017.08.06 229
RMVXA 플레이어가 이벤트에 접촉할수 있게 하는 방법좀 알려주세요. 10 file 크로마티안 2014.01.24 963
이벤트 작성 RMVXA 플레이어가 있는 위치에 죽는 이벤트를 등장하게 했을때 다른데 밟고 오지 않으면 죽지가 않아요 4 file 유리컵 2021.07.15 55
RMVXA 플레이어가 접근하면 반응하게... 4 닉네잉 2012.08.24 1532
이벤트 작성 RMVXA 플레이어가 추격자에게 잡혔을 경우 플레이어가 추격자와 마주봤으면 좋겠어요 3 루카_ 2022.01.21 174
RMVXA 플레이어가 파티원을 통과하지 못하게 할 수 있나요? 4 듀얼쇼크 2016.05.31 176
이벤트 작성 RMVXA 플레이어를 이벤트에 있는 위치로 이동시키고 싶습니다. 2 벌레황제 2019.01.19 645
RMVXA 플레이어의 모습이 보이지 않습니다. 4 file Sleep 2016.12.15 95
RMVXA 플레이어접촉설정시 멈추는 현상 6 file 푸른사신 2013.01.15 1009
RMVXA 플레이어한테 이벤트 2 여왕폐하 2016.03.07 123
RMVXA 플레이화면이 너무 작아요!ㅠㅠ 도트 픽셀이 하나하나 잘 보였으면 좋겠는데.. (해상도 낮추고싶어요) 9 file 당근양 2016.07.01 2330
RMVXA 피, 교복 같은 소재 어디서 구할 수 있나요? 아으아아앙 2013.04.26 785
RMVXA 피해를받고 반격할 수 있는 방법. 2 기폭 2015.07.10 220
Board Pagination Prev 1 ... 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 Next
/ 149