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.

Some Window and Scene_Battle Help

Let me just start off by saying that, as of this moment, I have officially ended a very heartfelt relationship with the RMXP "Window" :mad:

*sigh*

Okay, I'm making a window (called ActorTurn) to display whose turn it is by using actor graphics that I've placed inside a window, in battle. I've configured all the needed coding (Window_Base, Window_ActorTurn, and Scene_Battle), but it keeps popping up with a undefined "actor.character_name" when I've used this same way of displaying things before. For the life of me, I cannot figure out wtf is going wrong! :-[

Heres the coding:

Window_Base
Code:
  def draw_turngraphic(actor, x, y)
    turngraphic = RPG::Cache.picture("BattleFaces/" + actor.character_name + "Turn")
    tgw = turngraphic.width
    tgh = turngraphic.height
    src_rect = Rect.new(0, 0, tgw, tgh)
    self.contents.blt(x - tgw / 2, y - tgh, turngraphic, src_rect)
  end

Window_ActorTurn
Code:
class Window_ActorTurn < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(-15, 300, 147, 62)
    self.opacity = 0
    self.contents = Bitmap.new(width-32, height-32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for actor in $game_party.actors
    actor = $game_party.actors
    draw_turngraphic(actor, 0, 30)
    end
  end
end

Scene_Battle (I've configured everything throughout like dispose, update, etc. that's not the problem; i'm getting the error just as I enter battle)
Code:
@actorturn_window = Window_ActorTurn.new



Thanks!
 
Code:
    for actor in $game_party.actors
    actor = $game_party.actors
    draw_turngraphic(actor, 0, 30)
    end
Here you are iterating over every actor in the party, so far so good, but in the second line here you overwrite the local variable "actor" (which holds the actor-object for the current iteration-step) with the array, that contains all actors in the party. And then you are passing this local variable, which now holds an array to your drawing-function. But as the function expect an actor-object, which has the attribute "character_name" and an array doesn't has such an attribute you get an error.
I don't now what you want to accomplish but currently your iteration makes no sense, as even if you delete this line, you still are drawing all actor-graphics over each other.
Delete this complete for-loop use something like this:
Code:
actor = $game_actors[id]
draw_turngraphic(actor, 0, 30)
You need to replace "id" with the actor-id of the actor which turn it is. As i don't use the default BS i don't know how you can access this actor, but that should lead in the right direction.
 
MagicMagor;172181 said:
Code:
    for actor in $game_party.actors
    actor = $game_party.actors
    draw_turngraphic(actor, 0, 30)
    end
Here you are iterating over every actor in the party, so far so good, but in the second line here you overwrite the local variable "actor" (which holds the actor-object for the current iteration-step) with the array, that contains all actors in the party. And then you are passing this local variable, which now holds an array to your drawing-function. But as the function expect an actor-object, which has the attribute "character_name" and an array doesn't has such an attribute you get an error.
I don't now what you want to accomplish but currently your iteration makes no sense, as even if you delete this line, you still are drawing all actor-graphics over each other.
Delete this complete for-loop use something like this:
Code:
actor = $game_actors[id]
draw_turngraphic(actor, 0, 30)
You need to replace "id" with the actor-id of the actor which turn it is. As i don't use the default BS i don't know how you can access this actor, but that should lead in the right direction.


i tried this:

Code:
class Window_ActorTurn < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(-15, 310, 147, 62)
    self.opacity = 0
    self.contents = Bitmap.new(width-32, height-32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for @active_battler in $scene_battle
    actor = @active_battler
    draw_actor_turngraphic(actor, 0, 30)
    draw_actor_class(actor, 30, 34)
    end
  end
end

and also an alias below the scene_battles:

Code:
  alias start_phase2_showactorturn_later start_phase2
  def start_phase2
    start_phase2_showactorturn_later
    @actorturn_window.refresh
  end

and it popped up with an error in "each" for the the ActorTurn window...:-/
 

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