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 :)
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
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)
$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 get an error that says wrong number of arguements 0 for 1.
can you copy the code you put and post it
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')
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
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)