Zarok RPG Maker
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.



 
AccueilDernières imagesS'enregistrerConnexion
Le Deal du moment : -50%
Trottinette électrique OCEAN DRIVE A9 avec ...
Voir le deal
299.99 €

Partagez | 
 

 Placer des textes sur la map.

Voir le sujet précédent Voir le sujet suivant Aller en bas 
AuteurMessage
catskart
Atome
Atome
catskart


Masculin Messages : 48
Age : 25
Date d'inscription : 25/08/2012

Placer des textes sur la map. Empty
MessageSujet: Placer des textes sur la map.   Placer des textes sur la map. EmptyDim 16 Fév 2014 - 22:03


Tutoriel : Comment placer des textes sur la map.


Très utile si on fabrique de menu en événement et qu'on veux pas utiliser des pictures pour trois mots.


1/ Recréation d'un Windows base :

Tout d'abord, je vais recréer un Windows base qui sera le même que l'original... Mais sans le Windows skin (à moins qu'il y a une autre façon de le faire, mais j'ai trouvé cette méthode)

Voici le script, collez au-dessus de main dans la liste de script et nommez la "Window_Base2"

Code:
#==============================================================================
# ** Window_Base2
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#  Retrait du windowsskin par catskart
#==============================================================================

class Window_Base2 < Window
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x      : window x-coordinate
  #     y      : window y-coordinate
  #     width  : window width
  #     height : window height
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super()
    self.x = x
    self.y = y
    self.width = width
    self.height = height
    self.z = 100
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    # Dispose if window contents bit map is set
    if self.contents != nil
      self.contents.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # * Get Text Color
  #     n : text color number (0-7)
  #--------------------------------------------------------------------------
  def text_color(n)
    case n
    when 0
      return Color.new(255, 255, 255, 255)
    when 1
      return Color.new(128, 128, 255, 255)
    when 2
      return Color.new(255, 128, 128, 255)
    when 3
      return Color.new(128, 255, 128, 255)
    when 4
      return Color.new(128, 255, 255, 255)
    when 5
      return Color.new(255, 128, 255, 255)
    when 6
      return Color.new(255, 255, 128, 255)
    when 7
      return Color.new(192, 192, 192, 255)
    else
      normal_color
    end
  end
  #--------------------------------------------------------------------------
  # * Get Normal Text Color
  #--------------------------------------------------------------------------
  def normal_color
    return Color.new(255, 255, 255, 255)
  end
  #--------------------------------------------------------------------------
  # * Get Disabled Text Color
  #--------------------------------------------------------------------------
  def disabled_color
    return Color.new(255, 255, 255, 128)
  end
  #--------------------------------------------------------------------------
  # * Get System Text Color
  #--------------------------------------------------------------------------
  def system_color
    return Color.new(192, 224, 255, 255)
  end
  #--------------------------------------------------------------------------
  # * Get Crisis Text Color
  #--------------------------------------------------------------------------
  def crisis_color
    return Color.new(255, 255, 64, 255)
  end
  #--------------------------------------------------------------------------
  # * Get Knockout Text Color
  #--------------------------------------------------------------------------
  def knockout_color
    return Color.new(255, 64, 0)
  end
  #--------------------------------------------------------------------------
  # * Draw Graphic
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_graphic(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    cw = bitmap.width / 4
    ch = bitmap.height / 4
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end
  #--------------------------------------------------------------------------
  # * Draw Name
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_name(actor, x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 120, 32, actor.name)
  end
  #--------------------------------------------------------------------------
  # * Draw Class
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_class(actor, x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 236, 32, actor.class_name)
  end
  #--------------------------------------------------------------------------
  # * Draw Level
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_level(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, "Nv")
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Make State Text String for Drawing
  #     actor       : actor
  #     width       : draw spot width
  #     need_normal : Whether or not [normal] is needed (true / false)
  #--------------------------------------------------------------------------
  def make_battler_state_text(battler, width, need_normal)
    # Get width of brackets
    brackets_width = self.contents.text_size("[]").width
    # Make text string for state names
    text = ""
    for i in battler.states
      if $data_states[i].rating >= 1
        if text == ""
          text = $data_states[i].name
        else
          new_text = text + "/" + $data_states[i].name
          text_width = self.contents.text_size(new_text).width
          if text_width > width - brackets_width
            break
          end
          text = new_text
        end
      end
    end
    # If text string for state names is empty, make it [normal]
    if text == ""
      if need_normal
        text = "[Normal]"
      end
    else
      # Attach brackets
      text = "[" + text + "]"
    end
    # Return completed text string
    return text
  end
  #--------------------------------------------------------------------------
  # * Draw State
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_state(actor, x, y, width = 120)
    text = make_battler_state_text(actor, width, true)
    self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
    self.contents.draw_text(x, y, width, 32, text)
  end
  #--------------------------------------------------------------------------
  # * Draw EXP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_exp(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 34, 32, "Exp")
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 34, y, 84, 32, actor.exp_s, 2)
    self.contents.draw_text(x + 118, y, 12, 32, "/", 1)
    self.contents.draw_text(x + 130, y, 84, 32, actor.next_exp_s)
  end
  #--------------------------------------------------------------------------
  # * Draw HP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_hp(actor, x, y, width = 144)
    # Draw "HP" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      hp_x = x + width - 48
      flag = false
    end
    # Draw HP
    self.contents.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
    # Draw MaxHP
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw SP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_sp(actor, x, y, width = 144)
    # Draw "SP" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    # Draw SP
    self.contents.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
    self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
    # Draw MaxSP
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Parameter
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     type  : parameter type (0-6)
  #--------------------------------------------------------------------------
  def draw_actor_parameter(actor, x, y, type)
    case type
    when 0
      parameter_name = $data_system.words.atk
      parameter_value = actor.atk
    when 1
      parameter_name = $data_system.words.pdef
      parameter_value = actor.pdef
    when 2
      parameter_name = $data_system.words.mdef
      parameter_value = actor.mdef
    when 3
      parameter_name = $data_system.words.str
      parameter_value = actor.str
    when 4
      parameter_name = $data_system.words.dex
      parameter_value = actor.dex
    when 5
      parameter_name = $data_system.words.agi
      parameter_value = actor.agi
    when 6
      parameter_name = $data_system.words.int
      parameter_value = actor.int
    end
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 120, 32, parameter_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Draw Item Name
  #     item : item
  #     x    : draw spot x-coordinate
  #     y    : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_item_name(item, x, y)
    if item == nil
      return
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 28, y, 212, 32, item.name)
  end
end

2/ Création d'un texte :

Maintenant, on doit créer le "texte" à afficher sur la map.
Créez un événement à déclenchement automatique et clique droit/Insérer.../Page3/Insérer un script.
Dans la fenêtre de script, écrivez ceci :

Code:
class Message1 < Window_Base2
  def initialize
    super(0, 0, 640, 64)
# 160 et 96 correspondent à la longueur et largeur de la "fenêtre", vous pouvez le modifier.
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = Color.new(255, 255, 255, 255)
# correspondance des chiffres de couleurs (R,V,B,Alpha), vous pouvez changer la couleur.
    self.contents.draw_text(0, 0, 120, 32, "TAPEZ ICI !")
# 120 et 32 correspondent à l'espace réservé pour le texte, vous pouvez le modifier.
  end
end

Et ensuite, il ne reste plus qu'à le placer, on insert un autre script.

Code:
    @Message1_window = Message1.new
    @Message1_window.x = X - 8
    @Message1_window.y = Y - 4
# La valeur X et Y corresponde aux coordonné, remplacez X et Y par un nombre.
    @Message1_window.update

Et enfin, mettez la commande Effacer cet événement.

lancer le jeu et observer le travail !

Placer des textes sur la map. 110

3/ Afficher plusieurs texte d'un texte :

Si vous voulez afficher plusieurs méssages en même temps, vous refaites la même chose en remplaçant
les noms, par exemple, si c'est votre 2ème texte, remplacer Message1 et @Message1_window par
Message2 et @Message2_window, et pour le 3ème message, faites la même procédure et ainsi de suite.

Placer des textes sur la map. 1392586714-1


4/ Suppression du texte :

Maintenant, quand vous quittez le menu, vous voulez que le texte disparaît.

C'est tout simple ! il suffit juste d’insérer un script.
Code:

    @Message1_window.update
    @Message1_window.dispose

Et voilà, j'espère que ce tuto vous sera utile pour vos menu à événement ou autre chose. Wink


Dernier truc, si vous voulez que le windows skin soit présent, retirez juste le "2" de Window_Base2 dans les scripts de message.

ATTENTION : Dans cette méthode, les codes du messages ne fonctionne pas.
Si vous voulez affiché les valeurs, prenez ce script là : http://www.rpg-maker-detente.com/t137-afficher-une-variable-a-l-ecran


Dernière édition par catskart le Lun 17 Fév 2014 - 12:39, édité 2 fois
Revenir en haut Aller en bas
Kasbak
Kasbak


Masculin Messages : 1073
Date d'inscription : 03/01/2007

Caractéristiques du membre
Evolution: Atome
Job: Graphisme,events,scénario.
XP:
Placer des textes sur la map. Left_bar_bleue20/20Placer des textes sur la map. Empty_bar_bleue  (20/20)

Placer des textes sur la map. Empty
MessageSujet: Re: Placer des textes sur la map.   Placer des textes sur la map. EmptyLun 17 Fév 2014 - 12:18

Merci du partage,ça peu être utile,surtout pour les mini-jeux.
Revenir en haut Aller en bas
http://kasbakprod.wifeo.com/
Mimiko
Matière
Matière
Mimiko


Grade : Lapin lvl 2
Féminin Messages : 384
Age : 32
Loisirs : Rester dans mon coins à lire, écouter la musique, dessiner, ordinateur, Rm, RP (et le théâtre)
Date d'inscription : 30/04/2011

Caractéristiques du membre
Evolution: Animal
Job:
XP:
Placer des textes sur la map. Left_bar_bleue0/15Placer des textes sur la map. Empty_bar_bleue  (0/15)

Placer des textes sur la map. Empty
MessageSujet: Re: Placer des textes sur la map.   Placer des textes sur la map. EmptyLun 17 Fév 2014 - 19:44

c'est sympas pour mettre les pensés des personnages dans un jeux Very Happy
merci pour le partage cats Smile
Revenir en haut Aller en bas
http://miko-projet-cda-iriee.blogspot.fr/
catskart
Atome
Atome
catskart


Masculin Messages : 48
Age : 25
Date d'inscription : 25/08/2012

Placer des textes sur la map. Empty
MessageSujet: Re: Placer des textes sur la map.   Placer des textes sur la map. EmptyLun 17 Fév 2014 - 21:45

Mimiko a écrit:
c'est sympas pour mettre les pensés des personnages dans un jeux Very Happy
merci pour le partage cats Smile

De rien. ^^
Je pensais plus dans le cas où on fais des customs menu systems par évenement pour éviter les pictures.
Revenir en haut Aller en bas
Contenu sponsorisé



Placer des textes sur la map. Empty
MessageSujet: Re: Placer des textes sur la map.   Placer des textes sur la map. Empty

Revenir en haut Aller en bas
 

Placer des textes sur la map.

Voir le sujet précédent Voir le sujet suivant Revenir en haut 
Page 1 sur 1

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Zarok RPG Maker :: 

 :: TUTORIELS :: Tutoriels des système en Events
-
Sauter vers: