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

Status
Not open for further replies.

Joy

Veteran
Veteran
Joined
Aug 7, 2012
Messages
48
Reaction score
134
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
48
Reaction score
134
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
8,463
Reaction score
5,589
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.

Latest Threads

Latest Profile Posts

Add Film-like Visual Effects During Test-Play, Deploy Games with Electron | RPG Maker News #69

brain broken as soon as i figure out whats wrong with my game im taking a long nap
Hey guys anyone is interested in playing my game? Just PM me and I'll give you a Steam key! Here's my latest video! ->
cst.PNG
What would you assume this thing was/is?
1623528827049.png
Ah yes. Just the reference I was looking for to use for my portrait. Thanks Google.

Forum statistics

Threads
112,182
Messages
1,066,411
Members
145,775
Latest member
Nyakiryu
Top