Delete an object from UID

Get help using Construct 2

Post » Fri Nov 25, 2011 11:21 am

I have several spawned object.

On mouse over OBJECT_1 && Left button Clicked -> set global_var to OBJECT_1.UID

On mouse cursor over OBJECT_1 && Left button Released -> ???How do I do this: destroy UID???

I hope I was able to explain myself


EDIT: to be more clear. I stored the first object UID in a global variable, when I'm over the other object I want to destroy the first object, the one which UID I stored in the global var.0plus12011-11-25 13:44:56
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Fri Nov 25, 2011 11:55 am

Event subgroup of mouse release: objectToBeDestroyed->PickInstanceByUID(global_var) Action: objectToBeDestroyed->Destroy

Editing a project (capx) would be clearer.

B
34
S
8
G
6
Posts: 34
Reputation: 4,942

Post » Fri Nov 25, 2011 1:20 pm

@drpool, I tried what you said, it wouldn't work and upon inspectin the problem it looks like the sub-event checks if the mouse is over the instance picked with UID while I need to pick ANOTHER instance, completely different from the one where my button has been released
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Fri Nov 25, 2011 3:41 pm

Please somebody help.. I'm about to cry.

Here's the capx http://dl.dropbox.com/u/1606950/test.capx
(Requires random array plugin)

Why, why can't I delete the picked card instance...
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Fri Nov 25, 2011 4:29 pm

@0plus1: if I understood your problme, you want to click on a card, and after that on a second one. At that moment, you want to delete the previous one. If so, you can do it that way : http://dl.dropbox.com/u/1412774/cardV2.capx
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Fri Nov 25, 2011 4:32 pm

Well, I got it working somehow. One thing I don't understand why it's not working is the second check if the cursor is over any card. (I disabled it). I suspect it checks if it is over the same instance as in the check before...maybe someone else can clear this part. Right now it's deleting the selected card everywhere.

http://dl.dropbox.com/u/40417570/Tests/test_mod.capx
B
34
S
8
G
6
Posts: 34
Reputation: 4,942

Post » Fri Nov 25, 2011 4:50 pm

You just have to separate checking and picking
destroyByUID.capx
Last edited by Yann on Sun Sep 14, 2014 10:58 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Nov 25, 2011 11:10 pm

Thanks to everybody I learned a lot from each of you.

I ended up using Yann "code".
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Mon Nov 28, 2011 4:07 pm

Another question, the same capx file applies.

In the cardsDeal group. If I wanted to avoid the "dealing" of face cards, how should I do it?

I tried adding these conditions:

(RandomArray.At(cardsCounter) % 13)+1 != 11
(RandomArray.At(cardsCounter) % 13)+1 != 12
(RandomArray.At(cardsCounter) % 13)+1 != 13

On top of the loop but it doesn't work at all, it just stops as soon as the system finds a face value.

Also.. is it possible to test variable with || (OR) or %% (AND)?

Also, is possible to set/unset specific values at a specific index of the array?

For example I have a random array of 52, I already used the number 10 and I unset it, resulting in an array of 51 elements.

Thanks
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Mon Nov 28, 2011 8:20 pm

just do :
[code]On dealing
    Local Variable col
    Local Variable row
    
    System: set col to random(9)+1 (1 to 10)
    System: set row to random(4)+1 (1 to 4)
    System: set DealtCard to col*row[/code]

I see all that as a simple table that's why I use col and row instead of value and color.
I'm assuming your cardindexing is 1-based and that you begin counting with as, 2, 3, 4 etc

Basically all that will output a non face card


If you want to check if a card is a face from its index you just have to do a

[code]cardIndex%14 greater than 10[/code]

Other than that you can't use OR operator yet... juxtaposing condition is the same as AND

Also an array has a fixed dimension on X,Y and Z so you can't really unset things, just set them to 0...-1... anything that can carry the meaning of "unset"Yann2011-11-28 20:23:07
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Next

Return to How do I....?

Who is online

Users browsing this forum: Callan S, gamecorpstudio and 10 guests