UltimaForum

Wsparcie [VX] - Pytanie o HUD i grafikę

hubertwalczak8 - Wto 01 Lis, 2011 09:55
Temat postu: Pytanie o HUD i grafikę
Witam, w mojej grze którą robię u siebie, mam takie funkcje, że w pewnych momentach bohater zmienia grafikę (np. zostaje ninja :)), i myślałem że na HUD-zie też się zmieni grafika bohatera, ale zostaje taka sama. Skrypt HUD-u:
Kod:
################################################################################
 #                                                                              #
 #                      ~~~~~ Copyright 2009 SojaBird ~~~~~                     #
 #                               HUD BluePrint v3.2                             #
 #                                                                              #
 ################################################################################

 # To toggle the hud's display, just do a callscript "hud"
 # To set the hud's display, just do a callscript "hud(true)" or "hud(false)"

 module Module_Name; WLH = Window_Base::WLH
 ################################################################################
 # User Customazation
   Start_Display = false #true/false
   Opacity = 100 #0-255
   BG_Display = true #true/false
   Hide = true #true/false
   EXP_NAME = "E"
 ################################################################################
 # Don't touch below (if ure're not a scripter)
 ################################################################################
=begin #########################################################################
 Some standard value's you might want to use are allready pre-defiend so that you
 don't have to write the whole function for your self anymore.
 Here follows a list: (just copy+past and fill in the value's to let it work)
   * draw_actor_graphic(actor, x, y)
   * draw_actor_face(actor, x, y, size = 96)
   * draw_actor_name(actor, x, y)
   * draw_actor_class(actor, x, y)
   * draw_actor_level(actor, x, y)
   * draw_actor_state(actor, x, y, width = 96)
   * draw_actor_hp(actor, x, y, width = 120)
   * draw_actor_mp(actor, x, y, width = 120)
   * draw_actor_parameter(actor, x, y, type)
       FOR TYPE: 0=atk, 1=def, 2=spi, 3=agi
   * draw_item_name(item, x, y, enabled = true)
   * draw_currency_value(value, x, y, width)
   
   Custom new standard functions:
   * draw_actor_exp(actor, x, y, width = 120)
=end ###########################################################################
 ################################################################################
   def xywh
     @x = 0 #Set the x-position
     @y = 0 #Set the y-position
     @w = 96+32 #Set the width
     @h = 72+24+32 #Set the height
     return[@x, @y, @w, @h]
   end; def hud_values #Set the value's that you're using (also used at refresh)
     @actor = $game_party.members[@index]
     @temp_states = @actor.states
     #Example: @actor = $game_party.members[0]
   end; def hud_contents #Set the things you want to draw
     draw_actor_graphic(@actor, 14, 42)
     draw_actor_hp(@actor, 32, 0, 93-32)
     draw_actor_mp(@actor, 32, 24, 96-32)
     draw_actor_exp(@actor, 0, 48, 96)
     draw_actor_state(@actor, 0, 72, 96)
     #Example: draw_actor_hp(@actor, x, y)
   end; def hud_refresh?
     if @temp_actor != @actor or
     @temp_actor.character_name != @actor.character_name or
     @temp_actor.character_index != @actor.character_index or
     @temp_actor.hp != @actor.hp or
     @temp_actor.mp != @actor.mp or
     @temp_actor.exp != @actor.exp or
     @temp_states != @actor.states
     @temp_states = @actor.states
     #Example: if @actor != $game_party.members[0]
     return true; end
   end
 end
 ################################################################################
 # Don't touch below
 ################################################################################

 ################################################################################
 # Call script function
 ################################################################################
 def hud(arg = nil)
   $game_system.hud_display = !$game_system.hud_display if arg == nil
   $game_system.hud_display = arg if arg != nil
 end
 ################################################################################
 #------------------------------------------------------------
 # * Hud_Name: Create Hud window
 #------------------------------------------------------------
 class Hud_Name < Window_Base
   include Module_Name
   
   attr_reader :index
   
   def initialize(index)
     @index = index
     super(xywh[0],xywh[1],xywh[2],xywh[3])
     self.visible = $game_system.hud_display
     self.opacity = Opacity
     self.opacity = 0 if !BG_Display
     hide_status if Hide
     hud_values
     refresh
   end
   
   def refresh
     contents.clear
     hud_values
     hud_contents
   end
   
   def hide_status
     if Hide
       if $game_player.screen_x + 16 > self.x and
       $game_player.screen_y + 4 > self.y and
       $game_player.screen_x - 16 < self.x + self.width and
       $game_player.screen_y - 28 < self.y + self.height
         self.opacity = Opacity if BG_Display
         self.contents_opacity = Opacity
       else
         self.opacity = 255 if BG_Display
         self.contents_opacity = 255
       end
     end
   end
   
   def update
     self.visible = $game_system.hud_display
     return if !self.visible
     refresh if hud_refresh?
     hide_status if Hide
   end
 end

 #------------------------------------------------------------
 # * Scene_Map: Attach HUD to map
 #------------------------------------------------------------
 class Scene_Map < Scene_Base
   alias start_hud_name start
   alias terminate_hud_name terminate
   alias update_hud_name update
   def start
     start_hud_name
     @index = 0
     new_hud
   end
   def terminate
     @hud_name.dispose
     terminate_hud_name
   end
   def update
     update_hud_name
     @hud_name.update
     return if !@hud_name.visible
     if Input.trigger?(Input::R)
       if @index == $game_party.members.size - 1
         @index = 0
       else
         @index += 1
       end
     elsif Input.trigger?(Input::L)
       if @index == 0
         @index = $game_party.members.size - 1
       else
         @index -= 1
       end
     end
     new_hud if @index != @hud_name.index
   end
   def new_hud
     @hud_name.dispose if !@hud_name.nil?
     @hud_name = Hud_Name.new(@index)
   end
 end

 #------------------------------------------------------------
 # * Game_System: Check for display
 #------------------------------------------------------------
 class Game_System
   alias hud_initialize initialize
   attr_accessor :hud_display
   def initialize
     hud_initialize
     @hud_display = Module_Name::Start_Display
   end
 end

 #------------------------------------------------------------
 # * Window_Base: Some new standard function
 #------------------------------------------------------------
 class Window_Base < Window
   include Module_Name
   
   def draw_actor_exp(actor, x, y, width = 120)
     s1 = actor.exp_s
     s2 = actor.next_rest_exp_s + s1
     if s1.is_a? String or s2.is_a? String
       s1 = actor.exp
       s2 = actor.exp
     end
     draw_actor_exp_gauge(actor, x, y, s1, s2, width)
     self.contents.font.color = system_color
     self.contents.draw_text(x, y, 30, WLH, EXP_NAME)
     self.contents.font.color = normal_color
     last_font_size = self.contents.font.size
     xr = x + width
     if width < 120
       self.contents.draw_text(xr - 44, y, 44, WLH, s1, 2)
     else
       self.contents.draw_text(xr - 99, y, 44, WLH, s1, 2)
       self.contents.font.color = normal_color
       self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
       self.contents.draw_text(xr - 44, y, 44, WLH, s2, 2)
     end
   end
   
   def draw_actor_exp_gauge(actor, x, y, s1, s2, width = 120)
     gw = width * s1 / s2
     gc1 = text_color(31)
     gc2 = text_color(27)
     self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
     self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
   end
 end

Melvin - Wto 01 Lis, 2011 11:50

Chodzi Ci o battlera? Dodaj w zdarzeniu, oprócz zmiany chara, battlera.
Na przyszłość, wklejaj kody w tag "[code]".

hubertwalczak8 napisał/a:
Witam, w mojej grze którą robię u siebie

:kable:

hubertwalczak8 - Wto 01 Lis, 2011 11:57

Wkleiłem w code... O co ci chodzi? Chodzi mi o chara. Gdy zmieniam grafikę, w HUD-zie pozostaje stara.
Angius - Wto 01 Lis, 2011 12:07

Melvowi chyba chodziło o tagi
Kod:
[spoiler]

hubertwalczak8 - Wto 01 Lis, 2011 12:09

Dobra, ale proszę o pomoc.
Melvin - Wto 01 Lis, 2011 12:15

Angius, mój błąd ;x chodziło mi o spoiler :-P
Spróbuj ponownie wywołać skryptu HUD'a, przy zmianie grafiki.

Angius - Wto 01 Lis, 2011 12:17

A dokładniej wywołaj w zdarzeniu skrypt "hud"
hubertwalczak8 - Wto 01 Lis, 2011 12:19

Chodzi żeby wyłączyć i włączyć?
Angius - Wto 01 Lis, 2011 12:20

Albo update'ować.
hubertwalczak8 - Wto 01 Lis, 2011 12:22

Nie działa. Ciągle ta sama grafika na hudzie.
Angius - Wto 01 Lis, 2011 12:24

Jaką metodą go odświeżyłeś? Pokaż screena z edytora eventu.
hubertwalczak8 - Wto 01 Lis, 2011 12:25

Wywołałem skrypt hud(true), hud(false)
Angius - Wto 01 Lis, 2011 12:26

A wywołaj sam skrypt hud, bez dodatków w nawiasach.
hubertwalczak8 - Wto 01 Lis, 2011 12:27

No i nic. Ciągle stary char.
Melvin - Wto 01 Lis, 2011 12:32

Kod:
$scene = Scene_Map.new

Wywołaj w hudzie.

hubertwalczak8 - Wto 01 Lis, 2011 12:34

Chyba w skrypcie
Angius - Wto 01 Lis, 2011 12:35

W skrypcie, w skrypcie. Coś ci się dzisiaj wszystko myli, Melv :-P
Melvin - Wto 01 Lis, 2011 12:36

Co w skrypcie? :kable:
Wywołaj:
Kod:
$scene = Scene_Map.new

Daj to w czasie zmiany chara.

hubertwalczak8 - Wto 01 Lis, 2011 12:37

Nadal nic.
Angius - Wto 01 Lis, 2011 12:38

No w komendzie skrypt w evencie chyba?
Melvin - Wto 01 Lis, 2011 12:38

Nie możliwe. Pokaż ss okna zdarzenia z przemiany bohatera.
@UP:
Tak xD Chyba zejdę dzisiaj...

hubertwalczak8 - Wto 01 Lis, 2011 12:42

Masz tu linka:
http://imageshack.us/photo/my-images/714/hudq.png/

Melvin - Wto 01 Lis, 2011 12:52

Nie wiem co Ty robisz, ale ja właśnie sprawdziłem u siebie i działa. Nawet bez żadnego skryptu. Tylko przy zmianie grafiki gracza.
Angius - Wto 01 Lis, 2011 12:53

Pewnie z czymś się żre. Może inny skrypt nadpisuje wyświetlanie chara.
Melvin - Wto 01 Lis, 2011 12:54

Albo inaczej.

Zmień grafikę, nie tak jak teraz, tylko wejdź w 3 kartę edycji zdarzenia i zmień za pomocą "Change Actor Graphic".

hubertwalczak8 - Wto 01 Lis, 2011 12:57

@3UP
Napisałeś dokładnie jak ja? Bo mi się na pustym projekcie też nie działa.
EDIT: Już działa. :) Dzięx

Angius - Wto 01 Lis, 2011 12:59

Spróbuj zmienić grafikę bohatera trzecią kartą jak radzi Melv. Jeśli to nie kwestia żarcia się skryptów, musi działać.

Powered by phpBB modified by Przemo © 2003 phpBB Group