iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
 
Reply to this topicStart new topic
> Image commands, Need help with code
tincho
post Nov 19 2011, 08:46 PM
Post #1



Group Icon






im made a script whit multiple command windows, one of them must be whit images or icons, but i dont know how to replace text whith the images.

the code is this
CODE
class Scene_CuerpoFem < Scene_Base
  
  def start
    op1 = "Acolito"
    op2 = "Alquimista"
    @com3 = Window_Command.new(100,[op1,op2])
    @com3.x = 340
    @com3.height = 480
  end
  
  def update
    @com3.update
    
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Chara.new
    end
    
    if Input.trigger?(Input::C)
      case @com3.index
        when 0
        when 1
      end
    end
  end
end


i need that the commands, instead of appears in text, show images deposit in Graphics/Fbody

thanks



--------------------


Go to the top of the page
 
+Quote Post
   
tincho
post Nov 20 2011, 04:38 AM
Post #2



Group Icon






SOLVED!! just a litte

I decide to use a image instead of replace text for an image, now i see an imageen the back of selection, but i want to modify the size of the cursor to match the image.

now i need a code to rezise the cursor.



--------------------


Go to the top of the page
 
+Quote Post
   
Nelderson
post Nov 21 2011, 11:56 PM
Post #3



Group Icon


Type: Designer
Alignment: Lawful Good




Your best bet would be to make a new class with the same inheritance as the Window_Command class.

The easiest way would be to copy the Window_Command script, paste it, and rename Window_Command to something different.

EX:

Spoiler:
CODE
#==============================================================================
# ** Window_Command_Testing
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================

class Window_Command_Testing < Window_Selectable  ####THIS LINE HERE####
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :commands                 # command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width      : window width
  #     commands   : command string array
  #     column_max : digit count (if 2 or more, horizontal selection)
  #     row_max    : row count (0: match command count)
  #     spacing    : blank space when items are arrange horizontally
  #--------------------------------------------------------------------------
  def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
    if row_max == 0
      row_max = (commands.size + column_max - 1) / column_max
    end
    super(0, 0, width, row_max * WLH + 32, spacing)
    @commands = commands
    @item_max = commands.size
    @column_max = column_max
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index   : item number
  #     enabled : enabled flag. When false, draw semi-transparently.
  #--------------------------------------------------------------------------
  def draw_item(index, enabled = true)
    rect = item_rect(index)
    rect.x += 4
    rect.width -= 8
    self.contents.clear_rect(rect)
    self.contents.font.color = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(rect, @commands[index])
  end
end


Then in your scene script change the:

CODE
@com3 = Window_Command.new(100,[op1,op2])


to:

CODE
@com3 = Window_Command_Testing.new(100,[op1,op2])


Then you can fiddle with the new script you have to change the inherited methods out of Window_Selectable, to resize the cursor to what you see fit.

Note: The reason you would want a new Window_Command class, is because if you change the original Window_Command class, any changes will affect ALL the Command windows(Main Menu, Map menu, Battle Menu, etc....)

This post has been edited by Nelderson: Nov 22 2011, 12:00 AM


--------------------
STOP BEING A JAPFAG CRIMSON!!!

Meh.....F$#@ you Mike <=== Still applies....<_<
Go to the top of the page
 
+Quote Post
   
tincho
post Nov 22 2011, 04:28 AM
Post #4



Group Icon






QUOTE (Nelderson @ Nov 21 2011, 08:56 PM) *
Your best bet would be to make a new class with the same inheritance as the Window_Command class.

The easiest way would be to copy the Window_Command script, paste it, and rename Window_Command to something different.

EX:

Spoiler:
CODE
#==============================================================================
# ** Window_Command_Testing
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================

class Window_Command_Testing < Window_Selectable  ####THIS LINE HERE####
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :commands                 # command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width      : window width
  #     commands   : command string array
  #     column_max : digit count (if 2 or more, horizontal selection)
  #     row_max    : row count (0: match command count)
  #     spacing    : blank space when items are arrange horizontally
  #--------------------------------------------------------------------------
  def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
    if row_max == 0
      row_max = (commands.size + column_max - 1) / column_max
    end
    super(0, 0, width, row_max * WLH + 32, spacing)
    @commands = commands
    @item_max = commands.size
    @column_max = column_max
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index   : item number
  #     enabled : enabled flag. When false, draw semi-transparently.
  #--------------------------------------------------------------------------
  def draw_item(index, enabled = true)
    rect = item_rect(index)
    rect.x += 4
    rect.width -= 8
    self.contents.clear_rect(rect)
    self.contents.font.color = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(rect, @commands[index])
  end
end


Then in your scene script change the:

CODE
@com3 = Window_Command.new(100,[op1,op2])


to:

CODE
@com3 = Window_Command_Testing.new(100,[op1,op2])


Then you can fiddle with the new script you have to change the inherited methods out of Window_Selectable, to resize the cursor to what you see fit.

Note: The reason you would want a new Window_Command class, is because if you change the original Window_Command class, any changes will affect ALL the Command windows(Main Menu, Map menu, Battle Menu, etc....)


thank you very much!! you save my day, just tire of try rezise the F***ing square to fit the selection, now can i move to others issues that are more complex.

THANKS




--------------------


Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 31st July 2014 - 06:45 PM

RPGMakerVX.net is an Privacy Policy, Legal.