Can a Mouse Click Detect an objects UID?

0 favourites
From the Asset Store
Act on your instances, get/set their properties and variables only thanks to their UID. No more picking trouble! Plugin
  • Hi all,

    I am wondering if it is possible to have a mouse click detect an objects UID.

    I ask this because i have a good many of Dirt Tiles in my world and i want the player to be able to destroy and create them at will.

    The issue im having is when i destroy a tile it destroys all of my dirt tiles,I came to the conclusion that it must be some sort of issue on my part.Can anyone fill me in on this?

  • Shouldn't happen that way, it should only delete the tile you click on.

    This example I just created a square sprite, copy and pasted it a few times. Added the mouse object.

    On Object Click - Destroy

    https://www.dropbox.com/s/nr9isqh6daea8vr/clickdestroy.capx

  • Thank You ArcadEd i will check this out right now,I thought it was something that i was doing wrong.

  • Ok ArcadEd i think i see what i was doing wrong,I have All of my solid blocks that are bulding blocks in a family.I was destroying all solids.

    But after seeing this it looks like i have to create a seperate event for each Block tile i want to destroy in this fashion.Is this true?

  • Just change the Sprite to the Family.

    https://www.dropbox.com/s/80yc5xkoz5lty7h/clickdestroy-family.capx

  • Thanks ArcadEd to wrap things up i wanted to ask you do you know where i can see a good example of UIDs in a sandbox type of game?

    There are very few sandbox/tile game examples on how things are done.alot of them are terrain generation,But none on drawing animations onto tiles and making them look like they are breaking.

    Thanks again for helping me out.Awesome Website Aswell!!

  • I assume you mean like how Minecraft uses IDs for each of the items in the game? Probably the best thing to do is learn Arrays and how they work in construct. Then you can create an arrays with info on each ID.

  • ArcadEd Me and arrays dont get along the best,I have tried to learn them but fall short when it comes to making tiles appear.I am not the best at arrays thats why im looking for alternate routes.

    I think/Hope that i will be able to get around them since my world size is not as big as something like minecraft or terraria.

  • There are very few sandbox/tile game examples on how things are done.alot of them are terrain generation,But none on drawing animations onto tiles and making them look like they are breaking.

    There are dozen ways of doing that. It all depends what you want to do.

    Hold left mouse button on any block https://dl.dropboxusercontent.com/u/34375299/Construct%202/examples/dest.capx

  • shinkan   THAT IS EPIC!!! that looks awesome man do you mind if i mimic your style for the block breaking,I wont use your sprites i just want to learn from this.

    This is pretty awesome man.Thank you guys for helping,I have been getting alot of help as of late and i am very grateful to have people that care around.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well you can have it all. I made this example especially for you.

  • Well you can have it all. I made this example especially for you.

    Thank you shinkan seeing this really helped me out alot.

  • shinkan There is a bug in this capX,When i click one tile then the other a cracking sprite is left behind.It creates two cracking sprites and breaks the digging function.Is there a way to fix this?

  • Mouse: On Left button released -> Sprite2: Destroy

    Edit: This is very basic system. If You want to keep using it then You should really make some improvements. Like currently breaking block. While breaking the block try to move your mouse over different one. You will see that block over mouse cursor will be destoryed even when breaking animation is playing over completly different one.

  • Awesome i was trippin alittle when it broke,I have so much on my mind i could not even see that little aspect to fix this.Thanks I did manage to incorperate touch controls with your example and it works flawless.

    I want to know what you think about me using a premade grid to dictate where the player has the reach to set blocks? I figured it would be just as good as using arrays,the only issue i have is am i able to have the player place a block ingame but have it still snap to the grid? I dont want the player to go and lay a block but have it offsetting at an uneven position.

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