How do I move an object after second click?

Get help using Construct 2

Post » Mon Jan 28, 2013 9:49 am

Hey there,
I'm new at construct2 and now I have a little Problem...

I have constructed a little game, where you can choose an item an set it to a figure.
There is a list of items, created from a family which spawns the items. So I want to click on one item (sprite) and after this click I want to click on one of three slots to place it here.
The Slots are in a family to.

My Construct-Part of it looks like this:
http://www.bilder-hochladen.net/files/h4fx-j-1f0e.jpg


Could anyone help me please?
All the other functions like spawning the "ItemFrame" to highlight the clicked sprite do fine.

Thanks forward.
CamulaCamula2013-01-28 09:56:28
B
5
Posts: 18
Reputation: 661

Post » Mon Jan 28, 2013 10:01 am

Would be a bit easier if you posted .capx file of your game so we could test things and show the solution you :)

But, it seems like you are not picking an item that you are placing into a slot. I believe that is what you tried to do with 'ident' variable, that is not necessary at all. You can use 'UID' instead, which is Unique IDentifier for every object in game. Save that into 'lastClickedItem' and when clicking on slot, add condition 'select item by UID lastClickedItem'.

Be sure to check 'Picking'-section in the FAQ for better understanding on how it works! :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Mon Jan 28, 2013 10:19 am

Hi vee41,
sorry I can't post my .capx-file because the whole sourcecode belongs to my firm and I'm not able to publish that... :/

I've read the conditions about picking and changed my construct-part like you told me. Now it uses the UID and the item is not moving already... :(

I'm creating the items in a loop after a AJAX-Request using a switch-case for different types.
This is an own event and the mouse-function while clicking on a slot is an own event too. So the items had to be there, don't they?
B
5
Posts: 18
Reputation: 661

Post » Mon Jan 28, 2013 10:32 am

Here is a demo the hopefully clears it up a bit.

Slot demo

Is this anything like what you are looking for? :)

It should not matter how you create your items, if they exist when you are clicking them everything should be ok.
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Mon Jan 28, 2013 11:22 am

Oh my God... I'm so... *gnaah* Just had to unpin the items before moving... -_-' oh darn... how awkward...
Sorry for using your time vee41. :D

Knowledge about UID and picking helped me through this. Thanks for that!
B
5
Posts: 18
Reputation: 661


Return to How do I....?

Who is online

Users browsing this forum: Zebbi and 21 guests