[RMXP] [RGSS] BATTLER IMAGE NOT SHOWING
Posts
Pages:
1
So, then. I've run into another issue.
I've been working on my bestiary script, and then I realized something. The images of my enemy battlers are not changing whatsoever. It stays the first image no matter what I do.
Here's the script:
And here's the scene code.
In advance, thank you for your help.
AceTheMad
I've been working on my bestiary script, and then I realized something. The images of my enemy battlers are not changing whatsoever. It stays the first image no matter what I do.
Here's the script:
#==============================================================================
#
# My first RGSS Script. Hopefully, this works out well
#
# This is a standard bestiary script. It displays a list of enemies that
# you've encountered and their image and stats.
#
# Author: AceTheMad
#==============================================================================
class Window_Monster_Image < Window_Base
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize(enemy_window, x, y, width, height)
super(x, y, width, height)
self.contents = Bitmap.new(width - 32, height - 32)
@enemy_window = enemy_window
@enemies = $data_enemies.compact
@selected_enemy = 0
refresh
end
#-----------------------------------------------------------------------------
# * Gets the battler
#-----------------------------------------------------------------------------
def get_battler
RPG::Cache.battler(@enemy.battler_name, @enemy.battler_hue)
end
#-----------------------------------------------------------------------------
# * Draws the bitmap
#-----------------------------------------------------------------------------
def draw_battler(enemy, x, y)
bmp = RPG::Cache.battler(enemy.battler_name, enemy.battler_hue)
src_rect = Rect.new(0, 0, bmp.rect.width, bmp.rect.height)
self.contents.blt(x, y, bmp, src_rect, 150)
end
def update_cursor
if @selected_enemy >= 0
if Input.trigger?(Input::UP)
@selected_enemy -= 1
p "Up was pressed. Selected enemy is now" + @selected_enemy
end
if Input.trigger?(Input::DOWN)
@selected_enemy += 1
p "Down was pressed. Selected enemy is now" + @selected_enemy
end
else
@selected_enemy = 0
end
end
#-----------------------------------------------------------------------------
# * Refresh
#-----------------------------------------------------------------------------
def refresh
self.contents.clear
update_cursor
#p @enemy_window.item
draw_battler(@enemies[@selected_enemy],1,1)
end
end
class Monster_List < Window_Selectable
def initialize
super(0, 0, 220, 480)
@item_max = $data_enemies.compact.length
@commands = $data_enemies.compact
self.contents = Bitmap.new(width - 32, @item_max * 32)
@column_max = 1
refresh
self.index = 0
@selected_item = self.index
end
#-----------------------------------------------------------------------------
# * Item
#-----------------------------------------------------------------------------
def item
@commands && @selected_item >= 0 ? @commands[@selected_item] : nil
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = MBook::TEXT_SIZE
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
y = 4 + index * 32
self.contents.draw_text(0, y, 220, 32, $data_enemies.compact[index].name)
end
end
And here's the scene code.
#-------------------------------------------------------------------------------
# MonsterBook scene
#-------------------------------------------------------------------------------
class Monster_Book
#-----------------------------------------------------------------------------
# * Main Processing
#-----------------------------------------------------------------------------
def main
@list_window = Monster_List.new
@image_window = Window_Monster_Image.new(@list_window, 220, 0, 420, 320)
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@image_window.dispose
@list_window.dispose
end
def update
@image_window.update
@list_window.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to Menu screen
$scene = Scene_Menu.new
return
end
end
end
In advance, thank you for your help.
AceTheMad
My instincts are telling me that the line "bmp = RPG::Cache.battler(enemy.battler_name, enemy.battler_hue)" in Window_Monster_Image.draw_battler should actually be "bmp = get_battler" (or something along those lines), but, I don't have XP to test that theory out.
Interesting...Let me check that out.
UPDATE: Nope. Didn't help. Still staying the first image in the list of enemies.
UPDATE: Nope. Didn't help. Still staying the first image in the list of enemies.
Hrm. I'm wondering about the button processing in Window_Monster_Image.update_cursor.
*looks at Mechanima code*
Seems like I did it...
...something like this. Though, I grant this is VX Ace, and I'm not showing absolutely everything that could/did happen with this scene.
*looks at Mechanima code*
Seems like I did it...
class Robo_Pic < Window_Base def initialize super(172, 0, Graphics.width - 172, fitting_height(14)) end def show_pic(index) bitmap = Cache.picture("robot " + index.to_s) rect = Rect.new(0, 0, Graphics.width, Graphics.height) contents.blt(-190, 0, bitmap, rect) end end class Scene_RoboShop < Scene_Base def start super file = RPG::BGM.new() file.name = "I3-Modern - Anticipation" file.play @command = Robo_Command.new @command.set_handler(:cancel, method(:outta_here)) @command.set_handler(:ok, method(:robo_kay)) @background = Robo_Back.new(0, 0, Graphics.width, Graphics.height) @background.z = 0 @background.show_pic @pic = Robo_Pic.new @help = Robo_Help.new(0, Graphics.height - (24*4), Graphics.width, 24*4) @help.reset_text end def pic_update if $game_switches[128] == false @help.reset_text @help.add("Feel free to scroll the selections and when you're ready,") @help.add("return to MX 4. It should cost 12 scrap.") end index = @command.index + 1 @pic.contents.clear @pic.show_pic(index) end def update super pic_update end end
...something like this. Though, I grant this is VX Ace, and I'm not showing absolutely everything that could/did happen with this scene.
OK. So, I've identified the true problem. Issue is I'm not sure how to fix it. It seems that it's not correctly updating the currently selected enemy. It thinks that the cursor never moved past the first enemy.
UPDATE: I FINALLY GOT IT WORKING.
Turns out, it simply was not updating. Not sure why, but...X'D
UPDATE: I realized that I brute-forced it too much. It only works so well. Gonna try and do things right. How do I update the value of @selected_item to be the current self.index without freezing the screen?
UPDATE: Nvm. I found the right way on my own. This has been solved. Thank you for your help, guys!
UPDATE: I FINALLY GOT IT WORKING.
Turns out, it simply was not updating. Not sure why, but...X'D
UPDATE: I realized that I brute-forced it too much. It only works so well. Gonna try and do things right. How do I update the value of @selected_item to be the current self.index without freezing the screen?
UPDATE: Nvm. I found the right way on my own. This has been solved. Thank you for your help, guys!
Pages:
1