How do I capture x,y of object for function?

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hey again!

    Trying to get a little "fancier" and need to know how to make this happen. When I click on button (B1), it opens menu (A). From there, I select one of the two graphics which places an object (coding below).

    What I would like to do is setup a function so that when I click on B2 or B3 or B4, the object associated with that button (1, 2, 3, 4) is placed in there x,y coordinates. Below is what happens when I click one of the images and I hard-coded the x,y to test but I need it to be dynamic based on the button pressed.

    [CropSelectionMenu]

    ----+ Mouse: On Left button Clicked on CropSelectionBox

    -----> System: Toggle CropSelectionMenu

    ----+ System: Is CropSelectionMenu

    -----> System: Set layer "CropSelection" Visible

    // Need to position the new crop where the dirt plot "was". Also need a way to close out the crop selection menu.

    ----+ Mouse: On Left button Clicked on Corn_Image2

    -----> Dirt_Plot: Destroy

    -----> CornPlant2: Destroy

    -----> Strawberry: Destroy

    --------+ System: Is CropSelectionMenu

    ---------> System: Create object CornPlant2 on layer "Crops" at (132, 345), create hierarchy: False

    ---------> System: Set CropSelectionMenu to False

    ---------> System: Set layer "CropSelection" Invisible

    ----+ Mouse: On Left button Clicked on Strawberry_Image2

    -----> Dirt_Plot: Destroy

    -----> CornPlant2: Destroy

    -----> Strawberry: Destroy

    --------+ System: Is CropSelectionMenu

    ---------> System: Create object Strawberry on layer "Crops" at (132, 345), create hierarchy: False

    ---------> System: Set CropSelectionMenu to False

    ---------> System: Set layer "CropSelection" Invisible

    ----+ Mouse: On Left button Clicked on CropSelectionBox

    -----> System: Set layer "CropSelection" Invisible

    -----> System: Set MainMenuVisible to False

    Again, any help and/or guidance would be much appreciated, including links to other articles or vids (I've been looking into many so far but I could have missed a few).

    Tagged:

  • This might be a little simplistic for what you are looking for but, you could just record the Uid of the field you are trying to plant when you click on it. Then you don't need to pass the x, y values. You can just use the pick by uid event. Check out this example. Hopefully it will give you a starting place.

    drive.google.com/file/d/1x-pSSSw9a3n-0XJOdTIMZDaZzoeXRPmk/view

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This might be a little simplistic for what you are looking for but, you could just record the Uid of the field you are trying to plant when you click on it. Then you don't need to pass the x, y values. You can just use the pick by uid event. Check out this example. Hopefully it will give you a starting place.

    https://drive.google.com/file/d/1x-pSSSw9a3n-0XJOdTIMZDaZzoeXRPmk/view?usp=sharing

    Man, that is genius! I know it may look simple to you but to me, it's part of what put man on the moon.

    Going through it now to reverse engineer it and see how to implement it into my program. Will update accordingly.

    Thanks again for your time!

  • This might be a little simplistic for what you are looking for but, you could just record the Uid of the field you are trying to plant when you click on it. Then you don't need to pass the x, y values. You can just use the pick by uid event. Check out this example. Hopefully it will give you a starting place.

    https://drive.google.com/file/d/1x-pSSSw9a3n-0XJOdTIMZDaZzoeXRPmk/view?usp=sharing

    Ok, so I am way further than I was before however here's where I am running into struggles.

    In the example you provided, the number selected replaces (destroys) any existing number on that spot through the imagelist sprite font. On the menu I have, there are two pictures corresponding to what will be created (corn or strawberry sprite). How would I write it so any sprite that is there (dirt, corn or strawberry) is replaced by what is selected?

  • Definitely has given me just about everything I needed.

    What I'm missing is the "ItemList". In the example you provided, it puts numbers into the "placementLocation" box depending on the number touched/clicked on. I'm trying to put a sprite into one of those boxes but each time I try, it goes to the first box, not the second or third one I click on. It's like there should be some array or something.

  • Just use the System Create Object by Name action passing in the name of the object you want to create.

    Redownload the project and take a look.

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