Best Method for Adding Custom HUD Icons

pendranome

New member
Hey folks. I'm working on a mod and I'm trying to implement a rudimentary inventory system. I want to display the currently held items as a series of small icons next to the player's lifebar. I've already thought out the general steps I'll need to take but I'm not sure what script method I should use to display the icon. I'm confused as to if I should use the drawsprite method in a script somewhere of if I need to spawn a new entity instead. If I use drawsprite, how do I make it so the sprite persists until the item is used, at which point it should stop displaying. If I spawn the icon as an new entity, how do I place it in relation to the HUD as opposed to the actual game world? Which method would be less memory intensive? I've been looking in the forums and I found a topic that looked like it could help a while ago where the guy was trying to display equipped gems or something but I can't seem to find it anymore(should have bookmarked it) Anyway, I would really appreciate if someone could point me in the right direction.
 
Drawsprite will work but its cpu intensive not memory intensive you could also summon a entity that moves with the stage as a panel that would my prefered method.
 
pendranome : If you want to use drawsprite, you use it in updatescript. That's a generic answer cause there is update.c and updated.c which is always active when player is in a level (or in main menu too if you set it that way) and there's also personal updatescript which is only active when entity using that updatescript is active.

If you need example, try playing this Double Dragon Mini. In that demo, health is shown using icon drawn by drawsprite function.
It might not be what you asked but you can learn how to use drawsprite function with that demo :).

Hmmm... that reminds me that Castlevania Collab also use drawsprite function to display current subweapon but it's only for player 1.
 
Just for the record, it is generally a better idea to use updated in favor of update. This is because update triggers when an engine update cycle starts, and updated when it is mostly complete. It's best to draw your own stuff after the engine does its native work. This also ensures your custom HUD is reflecting the very latest information (hitpoints, icon status, etc.).

DC
 
Back
Top Bottom