[Solved] How do I create click and place UI to game?

0 favourites
  • 9 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • im trying to click with mouse on a button then an object is created on the mouse and follows the mouse until clicked again where it is then placed down... the way im doing it now works terribly so has anyone got a better way of doing it...

    heres how im doing it now;

    Variable PlaceObj = 0

    Mouse - On left button clicked on (button) - set PlaceObj to 1

    - Create obj (object) at mouse.x, mouse.y

    system - PlaceObj = 1 - Set position to round(mouse.x/16) * 16, round(mouse.y/16) * 16

    - Every tick

    mouse - on any click - set PlaceObj to 0

    - set position to self.x, self.y

    Issue with this is, it only lets me place one of each object.

    P.S Sorry i dont know how to import image, tried making it as clear as i can.

  • Try saving the UID of object created to a variable when it is created. Then add a Pick by unique ID condition to position that specific instance of the object under your mouse or place it.

  • Try saving the UID of object created to a variable when it is created. Then add a Pick by unique ID condition to position that specific instance of the object under your mouse or place it.

    Can you explain to me how i do this please, I'm not familiar with the UID and cannot find a relative UID tutorial.

  • Anyone know how to do this, surely there is a more simple way of creating a click and drop UI... for example tower defence/RTS style UI

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not sure completely what is meant by "it only lets me place one of each object". Do you mean that pressing the button, dragging and putting down an object only works once ever? Or that you'd like to press the button, drag, and then keep clicking to put down as many as you want?

  • I'm not sure completely what is meant by "it only lets me place one of each object". Do you mean that pressing the button, dragging and putting down an object only works once ever? Or that you'd like to press the button, drag, and then keep clicking to put down as many as you want?

    I mean so i press the UI button, the object follow my cursor, i then press the button again to release the object, then if i press that same object in the UI again, the one i previously placed, disappears, it seems like a simple fix but i am unfamiliar with the UID system.

  • Ahhh okay. Try putting this part of your events:

    [quote:2pvp0xki]system - PlaceObj = 1 - Set position to round(mouse.x/16) * 16, round(mouse.y/16) * 16

    • Every tick

    mouse - on any click - set PlaceObj to 0

    • set position to self.x, self.y

    As sub-events under the first one, not as seperate events in their own right. This will ensure Construct knows you mean the object it just created, not all of that object.

  • I've been away, see if this helps:

    https://www.dropbox.com/s/ik6hdyma5qjui ... .capx?dl=0

  • Thank you both for your help, the file was very helpful and i have it working now.

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