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.

[RESOLVED]Picture instead of windowskin? + Battler Position?

How do you change a part of a script to display a picture instead of a windowskin? Because I need different windows to have a picture displayed behind them which includes textures, which of course stretch when applied as a windowskin. Is there any easy way to do it?

EDIT: Scroll down to latest post.
 
While you could do it the way you described, it'd be far easier to go a different way: Setting the window's background transparency to invisible, and then display another picture instead. You do those things like this:

Code:
# changing a window's background to invisible

@window.back_opacity = 0 # ranges from 0 to 255
Code:
# displaying a sprite

@sprite = Sprite.new

@sprite.bitmap = Bitmap.new(filename) # filename has to be a string and without file extension

@sprite.x = @window.x + 2 #example for setting a sprite's x coordinate to be relative to the window; same works with y

@sprite.z = @window.z - 1 # example of setting a sprite's z-value relative to the window

Remember to dispose the sprite appropriately, depending on what RGSS version you're using.


So yeah, that's the way that'd be really easy and just requires some graphical editing in addition. If you really want it to be drawn from the Window class, then yes, it's possible as well, but would be overly complicated.
 
Thanks a lot, that works perfectly :)

EDIT: Hmm, another question, how would you do this for a window that swaps between being active and not being active? Obviously I don't want the picture behind to show while the window isn't meant to be visible. I tried this:

Code:
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])

    @actor_command_window.y = 160

    @actor_command_window.back_opacity = 160

    @actor_command_window.active = false

    @actor_command_window.visible = false

    @battle_command_sprite = Sprite.new

    @battle_command_sprite.bitmap = Bitmap.new("Graphics/Pictures/System/Battle_Command") # filename has to be a string and without file extension

    @battle_command_sprite.x = @actor_command_window.x #example for setting a sprite's x coordinate to be relative to the window; same works with y

    @battle_command_sprite.y = @actor_command_window.y + 0 #example for setting a sprite's x coordinate to be relative to the window; same works with y

    @battle_command_sprite.z = @actor_command_window.z - 1 # example of setting a sprite's z-value relative to the window

    if @actor_command_window.visible == true

      @battle_command_sprite.opacity = 255

    elsif @actor_command_window.visible == false

      @battle_command_sprite.opacity = 0

    end

 

(Main part is taken from Scene_Battle 1) Why doesn't this work?

EDIT2: Sorry, didn't want to make a new topic so I'll add on to this one. New question, which script handles the positioning of actor (not enemy) battlers and where is it? Because as far as I can tell they're just set by @battler.screen_y and @battler.screen_x, which doesn't appear to be set up at all. Or am I looking in the wrong place? Basically what I want to do is change the position of the actor battlers to be standing on the left hand side of the screen, just as a battler (not animated or anything) and I don't want to use a script like Atoas because I've already done a lot of editing to the default battle system.
 
OK, so I've found the bit of code which handles placing the actor graphics, but I really need help again. (Still need help with the first problem above too). I've edited the script that handles where it positions the actor battlers, but no matter how hard I try I can not get the figures right. Here is the code I've edited (lines 567-582) of Game_Actor:

Code:
  #--------------------------------------------------------------------------

  # * Get Battle Screen X-Coordinate

  #--------------------------------------------------------------------------

  def screen_x

    return 30

  end

  #--------------------------------------------------------------------------

  # * Get Battle Screen Y-Coordinate

  #--------------------------------------------------------------------------

  def screen_y

    if self.index != nil

      return self.index * 130 + 200

    else

      return 0

    end

  end

 

This puts all the actors to the left hand side of the screen. Like this:

Battle%20Problem.png


However, I need the actors to line up at an angle like this:

Battle%20System%20Mock%20Up.png


Also, because of how RMXP handles images, the battlers appear on top of each other, rather than behind each other. How do I sort this out? Thanks in advance.
 

MicKo

Member

1st problem :
[ruby]if @actor_command_window.visible == true
  @battle_command_sprite.opacity = 255
elsif @actor_command_window.visible == false
  @battle_command_sprite.opacity = 0
end
[/ruby]
Your problem is that it's in the main method, which is executed only once before the main loop part.
Basically you have this :
[ruby]def main
  1
  # Some code that will be executed only once, before the loop starts
  loop do
    2
    # Some code that will be executed each frame until Scene is changed
    break if $scene != self # Break the loop if Scene is changed
  end
  3
  # Some code that will be executed only once if the loop is broken
end
[/ruby]
So, here you put your code in 1, before the loop. Meaning that it checks if @actor_command_window is visible only once, before the loop.
You should put it somewhere in 2 (in a method that is called here like update, for example)
You don't really care about the 3 here since this part will be ignored until the battle is over.

2nd problem :
[ruby]def screen_x
  if self.index != nil
    return default_x - self.index * minus_x
  else
    return 0
  end
end
[/ruby]
Replace the default_x by the X value you want the first actor to be, and the minus_x by the X value you want to be between each actor.
For your other problem, you need to edit the screen_z method :
[ruby]def screen_z
  if self.index != nil
    return self.index
  else
    return 0
  end
end
[/ruby]
I didn't try, but it should work.
 

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