How to make a scroll-wheel based weapon selector

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By redstonecreeper8

I’m a completely noob to the whole gamedev thing (only been at it a couple days) but so far I have a character with platformer movement, a handful of tilesets, enemies that move toward the player, coins that increase your score, and 2 different weapons. One of them is a full-auto machine gun, and the other is a rocket launcher that is slow but does powerful AoE damage. My goal is to eventually have something like 5 or 6 weapons total, so what I want to do is have a list of weapon sprites always at the bottom of the screen, and by using the scroll wheel you can visually cycle through them to change a variable in the Player script that controls what gun you have equipped. I haven’t found many tutorials on the UI system, so a pointer in the right direction would be greatly appreciated as I’ve been stumped on this one for a little bit! :frowning:
Thanks in advance! :slight_smile:

:bust_in_silhouette: Reply From: a human

Here’s a way to check if the scroll wheel is being used, but I stole it from someone else who was trying to do zooming in and out. Anyways, full credit to Dodolta for finding this input:

if event is InputEventMouseButton:
     if event.is_pressed():
         if event.button_index == BUTTON_WHEEL_UP:
             item_equipped += 1
         if event.button_index == BUTTON_WHEEL_DOWN:
             item_equipped -= 1