Everydayyyyy, Girl's Day ! - Bibi/Ssozi
dim. 16 févr. 2014 - 16h24
Bonjour. J'ai un problème avec un script qui gère une barre de vie en images. Tout fonctionne bien seulement un problème se pose... toutes les images passe avant la barre de vie. Ce qui est très embêtant quand on ajoute des décors en premier plan... Donc je voudrais savoir quel est la commande à rajouter pour mettre la barre de vie en priorité sur toutes les autres ? (En script) Si quelqu'un pouvait m'aider ça me serait d'une très grande aide ! Merci d'avance Le script : [code]module PLAYER_HUD Toggle = true # Toggle's the hud Xcoord = 270 # Position Ycoord = 260 end class Window_Base < Window def draw_health(i=0,x=0,y=0) #=============================================================# # Small formula determines which picture should be displayed. # #=============================================================# q = (i * 10) # Total amount of pictures needed. w = ($game_party.actors[0].maxhp.to_f / q.to_f) # Hp per picture. for c in (1..q) a = (w * c) # Top hp range b = (w * c) - w # Low hp range if ($game_party.actors[0].hp > b && $game_party.actors[0].hp <= a) j = c end end # This is the siren effect. It is activated at low health and switches # the background graphic, making it appear to flash red. if $siren == 0 if i > 0 && i < 10 background = RPG::Cache.picture("HUD/" + "Background-" + (i.to_s)) else background = RPG::Cache.picture("HUD/" + "Background-EXT") end else if i > 0 && i < 10 background = RPG::Cache.picture("HUD/" + "Background-" + (i.to_s) + "-2") else background = RPG::Cache.picture("HUD/" + "Background-EXT-2") end end # This is the green health bar. The formula determins the ending number. # places pictures in intervals of 10 for each upgrade. Example: # No upgrade = Images: 1-10. First upgrade includes 1-20 (11-20 are new pics). # Look at pictures folder for a better understanding. if j != nil arc = RPG::Cache.picture("HUD/Health/" + (j.to_s)) else arc = nil end # Small red circle that flashes when low on health. if $alert > 0 siren = RPG::Cache.picture("HUD/alert-" + $alert.to_s) else siren = RPG::Cache.picture("") end cw = background.width ch = background.height src_rect = Rect.new(0, 0, cw, ch) self.contents.blt(x, y, background, src_rect) if arc != nil self.contents.blt(x, y, arc, src_rect) else end if $alert != nil self.contents.blt(x, y, siren, src_rect) else end end def draw_face(x, y) # Looks for the actors face named according to rmxp database # in folder pictures/HUD/ name = $game_party.actors[0].name face = RPG::Cache.picture("HUD/" + name) cw = face.width ch = face.height src_rect = Rect.new(0, 0, cw, ch) self.contents.blt(x, y, face, src_rect) end def draw_hud(x=0,y=0,orn=0) health = case $game_party.actors[0].maxhp # Change HP numbers here when 10 then 1 # Max HP at upgrade 1 when 20 then 2 when 30 then 3 when 40 then 4 when 50 then 5 when 60 then 6 when 70 then 7 when 80 then 8 when 90 then 9 when 100 then 10 # Max HP at upgrade 10# Max HP at upgrade 10 else health = 11 end draw_health(health,x,y + 70) draw_face(x + 459,y + 62) end end class Window_PlayerHUD < Window_Base def reset @old_hp = @actor.hp @old_sp = @actor.sp @old_max_hp = @actor.maxhp @old_siren = $siren @old_alert = $alert end def initialize super(PLAYER_HUD::Xcoord, PLAYER_HUD::Ycoord, 603, 228) self.contents = Bitmap.new(width - 32, height - 32) self.windowskin = RPG::Cache.windowskin("") self.opacity = 0 $siren = 0 $alert = 0 @actor = $game_party.actors[0] if @actor != nil reset refresh end end def refresh self.contents.clear draw_hud(0,0) reset end def update @actor = $game_party.actors[0] if @actor != nil if @old_hp != @actor.hp or @old_max_hp != @actor.maxhp or @old_siren != $siren or @old_alert != $alert refresh end end end end class Scene_Map alias phud_main main def main @phud = Window_PlayerHUD.new @phud.x = PLAYER_HUD::Xcoord @phud.y = PLAYER_HUD::Ycoord if PLAYER_HUD::Toggle == false @phud.visible = false else @phud.visible = true end phud_main @phud.dispose end alias phud_update update def update if PLAYER_HUD::Toggle == false @phud.visible = false else @phud.visible = true end @phud.update phud_update end end [/code]
dim. 16 févr. 2014 - 17h51
Je suis débutant dans la matière, mais il me semble que si dans le : [code] def initialize ... end[/code] Tu rajoutes un [code]self.z = x[/code] avec un X bien élevé (je sais plus à combien sont les autres), ça devrait être bon.
dim. 16 févr. 2014 - 17h56
Ah, je met un double post au cas ou tu lirais déjà le premier: [code] @phud.x = PLAYER_HUD::Xcoord @phud.y = PLAYER_HUD::Ycoord [/code] En rajoutant [code] @phud.z = 100000 #ou autre nombre bien élevé x) [/code] Juste en dessous, ça devrait être la même chose ^^
dim. 16 févr. 2014 - 18h09
Ça ne marche pas malheureusement...
dim. 16 févr. 2014 - 20h03
essai ca : [code]module PLAYER_HUD Toggle = true # Toggle's the hud Xcoord = 270 # Position Ycoord = 260 end class Window_Base < Window def draw_health(i=0,x=0,y=0) #=============================================================# # Small formula determines which picture should be displayed. # #=============================================================# q = (i * 10) # Total amount of pictures needed. w = ($game_party.actors[0].maxhp.to_f / q.to_f) # Hp per picture. for c in (1..q) a = (w * c) # Top hp range b = (w * c) - w # Low hp range if ($game_party.actors[0].hp > b && $game_party.actors[0].hp <= a) j = c end end # This is the siren effect. It is activated at low health and switches # the background graphic, making it appear to flash red. if $siren == 0 if i > 0 && i < 10 background = RPG::Cache.picture("HUD/" + "Background-" + (i.to_s)) else background = RPG::Cache.picture("HUD/" + "Background-EXT") end else if i > 0 && i < 10 background = RPG::Cache.picture("HUD/" + "Background-" + (i.to_s) + "-2") else background = RPG::Cache.picture("HUD/" + "Background-EXT-2") end end # This is the green health bar. The formula determins the ending number. # places pictures in intervals of 10 for each upgrade. Example: # No upgrade = Images: 1-10. First upgrade includes 1-20 (11-20 are new pics). # Look at pictures folder for a better understanding. if j != nil arc = RPG::Cache.picture("HUD/Health/" + (j.to_s)) else arc = nil end # Small red circle that flashes when low on health. if $alert > 0 siren = RPG::Cache.picture("HUD/alert-" + $alert.to_s) else siren = RPG::Cache.picture("") end cw = background.width ch = background.height src_rect = Rect.new(0, 0, cw, ch) self.contents.blt(x, y, background, src_rect) if arc != nil self.contents.blt(x, y, arc, src_rect) else end if $alert != nil self.contents.blt(x, y, siren, src_rect) else end end def draw_face(x, y) # Looks for the actors face named according to rmxp database # in folder pictures/HUD/ name = $game_party.actors[0].name face = RPG::Cache.picture("HUD/" + name) cw = face.width ch = face.height src_rect = Rect.new(0, 0, cw, ch) self.contents.blt(x, y, face, src_rect) end def draw_hud(x=0,y=0,orn=0) health = case $game_party.actors[0].maxhp # Change HP numbers here when 10 then 1 # Max HP at upgrade 1 when 20 then 2 when 30 then 3 when 40 then 4 when 50 then 5 when 60 then 6 when 70 then 7 when 80 then 8 when 90 then 9 when 100 then 10 # Max HP at upgrade 10# Max HP at upgrade 10 else health = 11 end draw_health(health,x,y + 70) draw_face(x + 459,y + 62) end end class Window_PlayerHUD < Window_Base def reset @old_hp = @actor.hp @old_sp = @actor.sp @old_max_hp = @actor.maxhp @old_siren = $siren @old_alert = $alert end def initialize super(PLAYER_HUD::Xcoord, PLAYER_HUD::Ycoord, 603, 228) self.contents = Bitmap.new(width - 32, height - 32) self.windowskin = RPG::Cache.windowskin("") self.opacity = 0 self.z = 300 $siren = 0 $alert = 0 @actor = $game_party.actors[0] if @actor != nil reset refresh end end def refresh self.contents.clear draw_hud(0,0) reset end def update @actor = $game_party.actors[0] if @actor != nil if @old_hp != @actor.hp or @old_max_hp != @actor.maxhp or @old_siren != $siren or @old_alert != $alert refresh end end end end class Scene_Map alias phud_main main def main @phud = Window_PlayerHUD.new @phud.x = PLAYER_HUD::Xcoord @phud.y = PLAYER_HUD::Ycoord if PLAYER_HUD::Toggle == false @phud.visible = false else @phud.visible = true end phud_main @phud.dispose end alias phud_update update def update if PLAYER_HUD::Toggle == false @phud.visible = false else @phud.visible = true end @phud.update phud_update end end[/code]
dim. 16 févr. 2014 - 20h16
Le truc c'est que le créateur de ce scripte n'affiche pas directement l'hud mais une windows (@phud) transparent avec l'hud comme contents =/
dim. 16 févr. 2014 - 21h08
Génial ça marche, tu as modifier quel ligne ?
dim. 16 févr. 2014 - 21h12
J'ai plutot ajouté une ligne (la122) " self.z = 300"
dim. 16 févr. 2014 - 21h12
Mais c'est pas ce que j'avais dit ? :'D
dim. 16 févr. 2014 - 21h17
Punaise c'était tout bête... (C'était la 141.) Oui Kuro c'est à peu prêt ce que tu as dit. xD Merci beaucoup Zouzaka.
dim. 16 févr. 2014 - 21h21
Si, mais l'endroit c’était au mauvais endroit je pense ^^' toi tu a modifier le Z après la création de la windows alors que moi je l'ai fait avant. @Kreiss> Derien
dim. 16 févr. 2014 - 23h28
Zouz, je t'ajoute des points, merci ! Je déplace aussi.
lun. 17 févr. 2014 - 10h22
[quote] Mais c'est pas ce que j'avais dit ? :'D [/quote] Ah ouaip pas vue ton 1er message ^^'