Advertisement
Maephel

animação de sprite por tecla

Sep 13th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.12 KB | None | 0 0
  1. #=================================================================
  2. #--------------- animação quadro a quadro-------------------------
  3. # By : Maephel
  4. # é necessário ter o imput_master do valentine
  5. # Personagem mostra uma animação quadro a quadro quando você
  6. # aperta "x"
  7. #-----------------------------------------------------------------
  8. module ATTK
  9.   # sufixo do gráfico do personagem atacando
  10.   # Para poder usar o script coloque o grafico do seu char
  11.   # atacando assim:
  12.   #Nomedochar-attk (Ex: hero01-attk
  13.   IMG_ATTK = "-attk"
  14.   # A tecla que faz atacar
  15.   ATTK_TECLA = (Input::Key['X'])
  16.   ATK_SWITCH = 0 #id da switch que vai ligar quando atacar
  17.   #0 para nenhuma
  18. end
  19. #-----------------------------------------------------------------
  20. # Fim da Edição
  21. #=================================================================
  22. class Game_Character
  23.   alias attk_initialize initialize
  24.   def initialize
  25.     attk_initialize
  26.     @atacando = false
  27.   end
  28. end
  29.  
  30. class Game_Player < Game_Character
  31.   alias attkgp_initialize initialize
  32.   alias attkgp_update update
  33.   def update
  34.     actor = $game_party.actors[0]
  35.     def img_attk?(actor)
  36.       begin
  37.         RPG::Cache.character(actor.character_name.to_s + ATTK::IMG_ATTK, actor.character_hue)
  38.       rescue
  39.         return false
  40.       end
  41.       return true
  42.     end
  43.     unless @atacando == true
  44.       if Input.trigger?(ATTK::ATTK_TECLA)
  45.         atacar
  46.       end
  47.     else
  48.       if Input.trigger?(ATTK::ATTK_TECLA) or moving? or @pattern >= 3
  49.         @step_anime = false
  50.         @anime_count = 0
  51.         @pattern = 0
  52.         @move_speed = 4
  53.         @character_name = actor.character_name
  54.         @atacando = false
  55.         if ATTK::ATK_SWITCH != 0
  56.           $game_switches[ATTK::ATK_SWITCH] = false
  57.         end
  58.       end
  59.     end
  60.     attkgp_update
  61.   end
  62.   def atacar
  63.     actor = $game_party.actors[0]
  64.     if img_attk?(actor)
  65.       @character_name = actor.character_name + ATTK::IMG_ATTK
  66.       #@move_speed = 8
  67.       @step_anime = true
  68.     end
  69.     @atacando = true
  70.     if ATTK::ATK_SWITCH != 0
  71.       $game_switches[ATTK::ATK_SWITCH] = true
  72.     end
  73.   end
  74. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement