Select and deselect instances (radio button style)

  • Hello,

    I'm working a while on this (simple?) problem, but I can't find a solution. I'm working on a strategy game and when you click a building it turns in the "move mode". Ok great, but I can't figure out how to deselect an instance when I click another Instance from the same object. There should be only one instance in move mode like radio buttons.

    Here is what I've done:

    Explaination:

    2/3: "mode_move" on/off state

    4: Button to create a new building and turn on the "mode_move"

    5: Clicking anywhere "mode_move" turns off and set the new building position

    6: Clicking anywhere "mode_move" turns off and set the previous building position when overlapping another building

    7: Clicking a building turns "mode_move" off for all instances and turns "mode_move" on for the clicked object

    I think event 7 does not work, so you can click multible buildings.

  • Not sure why so complicated. Or use drag&drop or use an boolean together with a position to mouse (every tick).

    If you use drag&drop, it does not need to be disabled. Unless the buildings have a state that does not allow them to move. But i dont see that in your events.

    Now you have all the drag&drop conditions.

    On drag start

    ___ Here you can set the boolean, if you need it

    On drop

    ___ Here you can unset the boolean

    ___ Reposition (snap) if need

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you, that helped me a lot.

    I want that you first need to click once the building before you kann move it, to prevent accidently move a building while scrolling over the map.

    I solved it with a group in this way:

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)