3
$\begingroup$

So I'm making a GUI for my first person shooter type of game and I'm having trouble with making the effect for scrolling through the icons, trying to select one at a time instead of all. I basically have no idea how to do it so my question is, does anyone know how to use the mouse to scroll through the icons instead of selecting them all? I know why it selects them all I just want to know how to select them one at a time using the mouse wheel to go up and down the icons.

Here's a link to what I'm trying to make overall (https://www.youtube.com/watch?v=ALGcJVFb5oo) but as or right now I just need help getting the icon selection part right.

You can check out the blend file here- https://www.dropbox.com/s/p0312glj761zaei/SAO%20Ui.blend?dl=0

The only controls I have so far is when you press E it brings down the menu and when you use the wheel on the mouse it selects the icon (which is what I'm having trouble with...)

$\endgroup$
5
  • $\begingroup$ you are activating them all at the same time $\endgroup$
    – Chebhou
    Commented Apr 27, 2015 at 22:24
  • $\begingroup$ I realize that its just the problem is how do i select them one at a time $\endgroup$ Commented Apr 27, 2015 at 22:28
  • $\begingroup$ one send message to the next to get active , or you'll have to do some scripting $\endgroup$
    – Chebhou
    Commented Apr 27, 2015 at 22:29
  • $\begingroup$ any suggestions on how to start either of those $\endgroup$ Commented Apr 27, 2015 at 22:32
  • $\begingroup$ OK incrementing a property would be better , I'll try... $\endgroup$
    – Chebhou
    Commented Apr 27, 2015 at 22:34

1 Answer 1

4
$\begingroup$

You can use a property to hold the selected circle index, then switch between them each time the mouse-wheel rotate.

the easiest way was the script, the script is attached to the first circle as follows :

enter image description here

the first circle has two properties selected "the index of the selected circle" and open "indicates whether the menu is open or not"

enter image description here

here is the script used in the file :

def switch_selected():
    #get this controller   
    cont = bge.logic.getCurrentController()
    # the object running the script "1st cicle selected"
    owner = cont.owner
    # get this scene and a list of its objects
    scene = bge.logic.getCurrentScene()
    objects = scene.objects

    #hide all circles  to clear the previous selection ( also in case the menu is closed no circle is selected)
    objects['1st cicle selected'].visible = False
    objects['2nd Circle Selected'].visible = False
    objects['3d cicle Selected'].visible = False
    objects['4th Circle Selected'].visible = False
    objects['5th cicle Selected'].visible = False        

    #check if menu is open
    if owner['open'] :
        #get the mouse wheel sensors 
        mouse_up = cont.sensors["up"]
        mouse_down = cont.sensors["down"]

        #if mouse up increment index
        if mouse_down.positive :
            owner['selected'] += 1
            if owner['selected'] > 4 :
                owner['selected'] = 0
        #if mouse down decrement index
        if mouse_up.positive :
            owner['selected'] -= 1
            if owner['selected'] < 0 :
                owner['selected'] = 4   

        # read the index and set the selected to be visible
        selected = owner['selected']       
        if selected == 0 :
            objects['1st cicle selected'].visible = True
        elif selected == 1 :
            objects['2nd Circle Selected'].visible = True
        elif selected == 2 :
            objects['3d cicle Selected'].visible = True
        elif selected == 3 :
            objects['4th Circle Selected'].visible = True
        elif selected == 4 :
            objects['5th cicle Selected'].visible = True


switch_selected() #a call for the above function at each tick

Here is the file

enter image description here

$\endgroup$
2
  • $\begingroup$ Dude thank you soooo much!! I couldn't get this figured out for days!! Thanks you $\endgroup$ Commented Apr 28, 2015 at 0:18
  • $\begingroup$ @CloudyCastle71 you are welcome, and if you see that this solve your problem mark the answer as accepted ( the check mark on the left ) $\endgroup$
    – Chebhou
    Commented Apr 28, 2015 at 0:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .