Hello again, fellas, you guys are quite helpful for my learning, I'm a little slow, but I think I'm getting there.
I have made a script that displays an item icon and the amount received at the players location.
I doubt it's optimized but I'm just trying to get a feel for how things work.
I had thought that update was called all the time, so if I was to move a sprite in the update method it would continue until
I told it to stop, but I can't seem to get my sprite to continually stay at the players x position.
Could you look at this script and offer some advice, please?
I have made a script that displays an item icon and the amount received at the players location.
I doubt it's optimized but I'm just trying to get a feel for how things work.
I had thought that update was called all the time, so if I was to move a sprite in the update method it would continue until
I told it to stop, but I can't seem to get my sprite to continually stay at the players x position.
Could you look at this script and offer some advice, please?
Code:
class S_Pickup_Display < Scene_Map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~ SookyLala's item pickup display ~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~ SETTINGS: ~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
$gold_icon = 262 # Icon Index Number, found in the bottem left corner
# when choosing an icon for items/skills
$pickup_sound = 'Audio/SE/Item3'
def initialize(itemID, itemAmount)
$itemDisplayTime = 0
if itemID == "g"
@itemID = "g"
else
@itemName = $data_items[itemID]
end
@itemAmount = itemAmount
@xAmount = "x" + itemAmount.to_s
start
Audio.se_play($pickup_sound ,100,100)
end
def start
display_item
give_item
update
end
def display_item
if @itemID == "g"
itemName = $gold_icon
else
itemName = @itemName.icon_index
end
rect = Rect.new(itemName % 16 * 24, itemName / 16 * 24, 24, 24)
$itemDisplay = Sprite.new
$itemDisplay.bitmap = Bitmap.new(rect.width + 80 ,24)
bitmap = Cache.system("Iconset")
$itemDisplay.bitmap.draw_text($itemDisplay.bitmap.rect, @xAmount, 1)
$itemDisplay.bitmap.blt(0, 0, bitmap, rect)
$itemDisplay.x = $game_player.screen_x - 20
$itemDisplay.y = $game_player.screen_y - 10
end
def give_item
if @itemID == "g"
$game_party.gain_gold(@itemAmount)
else
$game_party.gain_item(@itemName, @itemAmount)
end
end
def update
$itemDisplay.x = $game_player.screen_x - 20
end
end