displaying an icon

Started by Noob, January 17, 2011, 05:52:33 pm

Previous topic - Next topic

Noob

hey i'd like to now how to display a small 24 x 24 icon in the upper right corner of the game screen. i'd like someone to please tell me the code commands for calling and dismissing it.  thanks :)

nathmatt

does it need to update if not just do this to make it
$Icon = Sprite.new
$icon.x,$icon.y = x,y # the x and y you want it to be
Icon.bitmap = RPG::Cache.icon(filename) # the icon name

and just use
$icon.dispose # to remove  it
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Noob

It fails :( it gives me a long error list a little similar to the one it gives if you put the main script above other scripts. Odd. I used an event to call this script:
$Icon = Sprite.new
$icon.x,$icon.y = 100,100 # the x and y you want it to be
Icon.bitmap = RPG::Cache.icon(testicon) # the icon name
Anything I did wrong? (I tried getting rid of the comments and that didn't help)

ForeverZer0

January 18, 2011, 07:48:29 pm #3 Last Edit: January 18, 2011, 07:49:33 pm by ForeverZer0

$icon = Sprite.new
$icon.x, $icon.y = 600, 16
$icon.bitmap = RPG::Cache.icon(ICON_NAME)


Use that in a script call. Replace ICON_NAME with the filename of the icon. It needs to be written as a string, with quotation marks around it. For example, if your icon's filename was test. You would set the icon's bitmap like this:


$icon.bitmap = RPG::Cache.icon('test')


You need to use the the script call to dispose it when you no longer need it. Here is a safer method that won't crash the game if the icon has already been disposed.


if $icon != nil && !$icon.disposed?
 $icon.dispose
end



The icon obviously has to be in your Graphics/Icons directory as well.
Hope that was helpful.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Noob

I get an error that says wrong number of arguements 0 for 1.

nathmatt

can you copy the code you put and post it
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Noob

Sure, here's what I tried after importing my 24 X 24 icon, testicon.
$icon = Sprite.new
$icon.x, $icon.y = 600, 16
$icon.bitmap = RPG::Cache.icon
('testicon')

nathmatt

here this should make it easier in an event script command use show_image(image) image should be the image name so use show_image('testicon') for you example then use remove_image to get rid of it
class Interpreter
 
  def show_image(image)
    @icon = Sprite.new
    @icon.x, $icon.y = 600, 16
    @icon.bitmap = RPG::Cache.icon(image)
  end
 
  def remove_image
    @icon.dispose if @icon != nil && !@icon.disposed?
  end
 
end
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


ForeverZer0

Quote from: Noob on January 19, 2011, 05:19:40 pm
Sure, here's what I tried after importing my 24 X 24 icon, testicon.
$icon = Sprite.new
$icon.x, $icon.y = 600, 16
$icon.bitmap = RPG::Cache.icon
('testicon')



You changed the code.
The () have to be right after the call.
If it doesn't fit on the same line, set the filename to a variable in the line before it.

name = 'FILENAME'
$icon.bitmap = RPG::Cache.icon(name)


I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.