0 Favourites

Delete an object from UID

  • 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.

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

    Editing a project (capx) would be clearer.

  • 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

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

    Here's the capx dl.dropbox.com/u/1606950/test.capx

    (Requires random array plugin)

    Why, why can't I delete the picked card instance... <img src="smileys/smiley19.gif" border="0" align="middle" />

  • 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

  • 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.

    dl.dropbox.com/u/40417570/Tests/test_mod.capx

  • You just have to separate checking and picking

    destroyByUID.capx

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

    I ended up using Yann "code".

  • 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

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • just do :

    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

    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

    cardIndex%14 greater than 10

    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"

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