[RGSS2] How to make images appropriately overlap[SOLVED]

Status
Not open for further replies.

Joy

Veteran
Veteran
Joined
Aug 7, 2012
Messages
47
Reaction score
113
First Language
English
Primarily Uses
N/A
Hey all, question for VX scripting.

I'm making some changes to the Battle Processing scene to show a row of thin facebars for the party with their current states. I'm wanting to use an image to replace the windowskin so that I'm not limited to the hard 16px margin around content, but the images are conflicting with the others' (x, y) draw.

what I want to do:
Annotation 2020-06-21 171104.png
So that the background window is the image and it draws the faces appropriately (the face draw works perfectly fine over a standard window or without the image being drawn behind them)

What is happening:
Annotation 2020-07-12 173129.png

Here's my current script noodling about:
Code:
class Window_BattleFace < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(-16, 272, 672, 100) #416
    self.windowskin = Cache.system("")
    refresh
    self.active = false
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    super
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.members.size
    for i in 0...@item_max
      draw_item_face(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : Item number
  #--------------------------------------------------------------------------
  def draw_item_face(index)
    rect = item_rect(index)
    rect.x += 0
    rect.y += 0
    rect.width -= 0
    self.contents.clear_rect(rect)
    self.contents.font.color = normal_color
    actor = $game_party.members[index]
    draw_face_back
    draw_actor_bface(actor.id, 4 + index % 4 * 152, 0) # 152
    draw_actor_state(actor, 116 + index % 4 * 152, 0, 48) #112
  end 

  def draw_actor_bface(id, x, y)
    bitmap = Cache.bface(id)
    #contents.blt(0, 0, bitmap, rect, 255)
    self.contents.blt(x, y, bitmap, bitmap.rect)

  end
 
  def draw_face_back
    #Sprite.new
    #rect = Rect.new(0, 0, 0, 0)
    bitmap = Cache.bfaceback
    self.z = +0
    self.contents.blt(0, 0, bitmap, bitmap.rect)

    bitmap.dispose
  end
 
end

module Cache
  def self.id_to_name(id)
    if id < 10
    filename = "00" + id.to_s
    elsif id < 100
    filename = "0" + id.to_s
  end
  return filename
  end
  def self.bface(id)
    filename = id_to_name(id)
    # The directory in which the face graphics are stored
    load_bitmap("Graphics/Battle Faces/", filename)
  end
 
  def self.bfaceback
    filenamebar = "facebar"
    load_bitmap("Graphics/Battle Faces/", filenamebar)
  end

end

#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
#  This window displays the status of all party members on the battle screen.
#==============================================================================

class Window_BattleStatus < Window_Selectable
  attr_accessor :message_x
  attr_accessor :message_y
  attr_accessor :message_width
  attr_accessor :message_height
  @message_width = 640
  @message_height = 86
end

#==============================================================================
# ** Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
  attr_accessor :message_x
  attr_accessor :message_y
  attr_accessor :message_width
  attr_accessor :message_height
  @message_width = 640
  @message_height = 86
    
  def start
    super
    $game_temp.in_battle = true
    @spriteset = Spriteset_Battle.new
    @message_window = Window_BattleMessage.new
    @face_bar_window = Window_BattleFace.new   
    @action_battlers = []
    create_info_viewport
    $game_message.clear
  end
 
  #--------------------------------------------------------------------------
  # * Create Information Display Viewport
  #--------------------------------------------------------------------------
  def create_face_viewport
    @info_viewport = Viewport.new(0, 288, 544, 128)
    @info_viewport.z = 100
    @status_window = Window_BattleStatus.new
    @party_command_window = Window_PartyCommand.new
    @actor_command_window = Window_ActorCommand.new
    @status_window.viewport = @info_viewport
    @party_command_window.viewport = @info_viewport
    @actor_command_window.viewport = @info_viewport
    @status_window.x = 128
    @actor_command_window.x = 544
    @info_viewport.visible = false
  end
  #--------------------------------------------------------------------------
  # * Dispose of Information Display Viewport
  #--------------------------------------------------------------------------
  def dispose_face_viewport
    @status_window.dispose
    @party_command_window.dispose
    @actor_command_window.dispose
    @info_viewport.dispose
  end
  #--------------------------------------------------------------------------
  # * Update Information Display Viewport
  #--------------------------------------------------------------------------
  def update_face_viewport
    @party_command_window.update
    @actor_command_window.update
    @status_window.update
    if @party_command_window.active and @info_viewport.ox > 0
      @info_viewport.ox -= 16
    elsif @actor_command_window.active and @info_viewport.ox < 128
      @info_viewport.ox += 16
    end
  end 
end

Thanks in advance!
 

Joy

Veteran
Veteran
Joined
Aug 7, 2012
Messages
47
Reaction score
113
First Language
English
Primarily Uses
N/A
This can be closed, figured out a solution!
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
6,996
Reaction score
4,740
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

What is your favourite rpg maker plugin?
Hopefully this gets fixed before release..
Where's this sudden heatwave come from? It's not even sunny, it's just hot. Hate it!
I'm slightly disappointed that the MZ codebase still uses core.js, managers.js, objects.js, scenes.js, sprites.js and windows.js instead of core/Bitmap.js, core/Graphics.js, managers/AudioManager.js, managers/DataManager.js, etc...
just a few more hours until the toughest, most pressure 72 hours of my life, wish me luck guys

Forum statistics

Threads
100,565
Messages
977,269
Members
132,148
Latest member
jcamp10565
Top