Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

need help adding picture in window_battleStatus

KAIRE

Member

so im adding face graphic of characters in my window_battlestatus. but the image cover eevrything there. such as the HP,MP, Bars, Stats, etc. how can i make the face picture behind everything else?

the codes. i add this in window_base
Code:
def draw_actor_battler_face(actor, x,y)
  face = RPG::Cache.character("BattlerFaces/" + actor.character_name, actor.character_hue)
    fw = face.width
    fh = face.height
  src_rect = Rect.new(0, 0, fw, fh)
  self.contents.blt(x - fw / 23, y - fh, face, src_rect)
end

then i add this in window_battlestatus above draw_actor_name

draw_actor_battler_face(actor, x, y)

i have also tried to put that below everything else but the picture still cover everything else.

how can i fix this?
 
First, let's fix that code.
Code:
class Window_Base
  def draw_face(actor, x, y)
    bitmap = RPG::Cache.character("BattlerFaces/#{actor.character_name}", actor.character_hue)
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height)
  end
end

Now above this line : draw_actor_name(actor, actor_x, 0)
Add : draw_face(actor, actor_x, 0)
 

KAIRE

Member

your code doesn't work... it give me an error. (highlight in red)
Code:
class Window_Base
  def draw_face(actor, x, y)
    bitmap = RPG::Cache.character("BattlerFaces/#{actor.character_name}", actor.character_hue)
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height)
  [COLOR=Red]end[/COLOR]
end

atleast my code shows the pictures. so what's wrong with my code? i just need to make the picture behind everything else. just tell me how to do that. or perhaps give me a code that works please...
 
The error probably results because you pasted the code inside the current Window_Base-Body instead of a new script.

As why your face is above everything else, that is the result of the drawing order.

In your actuall battlestatus-window you will find something like this:
Code:
self.contents.clear
draw_name(actor, x, y)
# ..
# You added your new line probably at the end of all this
draw_actor_battler_face(actor, x, y)
A bitmap is just a bunch of pixels, there are no layers or z-coordinate to determine what is above what, so the order in which you draws becomes important.
At first the bitmap is cleared, you get a fresh bitmap. Then several things like names, hp and mp are drawn upon it, so the pixels in the bitmap will be filled to draw these strings.
And then your picture gets blit upon it. Blitting is just copying a group of pixels from one bitmap to another. Because your picture is so big it occupies pixels that are currently representing the name-string or the hp or other things that are already drawn. But the blitting operation just copys your complete picture over this and the strings etc.. will be overdrawn.

To have your picture behind everything else you need to draw it first after the clearing, then everything else will be drawn upon it.
Code:
self.contents.clear
# Now your picture
draw_actor_battler_face(actor, x, y)
# now all the text
draw_name(actor, x, y)
draw_hp(actor, x, y)
# ....
 

KAIRE

Member

oh wow that sure fixed it! haha

thank you SephirothSpawn and others for the help and the detail explaination and the codes

thank you tibuda for pointing out the error and post the fix.

i have another question, is it ok if i just post it here? that's not the question lol... ok the question is...

how can i make it so the picture only shows when the actor are active for command. for example if it's actor 1 turn. his picture shows. if not it's just blank(no picture show). how can i do something like that?
 

KAIRE

Member

ok thanks for looking into it.

i was thinking i might need a new scene or window... like window_faceinbattle or something. and in scene_battle call the window. @battleface_window = window_faceinbattle.new set visible = false and somewhere in scene_battle 3. when @actor_command_window is true add under that, @battleface_window.visible = True...

or something like that? i was playing around with the script since i know a litle about scripting. but didn't quite get it to work at all. well atleast i try to come up with my own script. although i failed at doing so. haha
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top