How do I pick UID in context

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

    I made a transparent sprite who spawn one or more sprite.

    Sprite instance generated have instance variables as a keyboard key (like 'R' for representing 'R' of the keyboard and a Red bullet on the player's screen)

    Each time a sprite is spawn, i put the uid's sprite in an array

    when a sprite spawned meets a condition that is too late for player for typping the key, i remove the uid in my array and i destroy the sprite (referenced by condition on Sprite)

    A user's action can make destroy before meeting condition just explain before by typping the good key.

    I want to destroy the first Sprite who correspond in my array to the key pressed.

    this is a representation of my array when users press a key

    [0]=32

    [1]=33

    [2]=35

    [3]=36

    [4]=37

    [5]=38

    [6]=39

    [index] = uid of sprite

    I have already made a loop on the array to find Sprite by uid and find the first Red Bullet sprite to destroy and then stop loop

    My question is about how to find the first instance with key=='R' in their instance variable.

    Can somebody explain or show me an example?

    I check for uid documentation but i only found that uid is unique and defined at runtime now the way to get the Object behind an UID.

    Thanks a lot!

  • this is my condition/subcondition and actions

    (i use the example with 'R' key pressed

    Condition/subcondition :

    System => For "bulletsLoop" 0 to bulletsAlive.Width

    System => Bullet(bulletAlive.At(loopindex)).key == "R"

    Actions :

    ...

    bulletsAlive => delete loopindex from X axis //keep the array up to date

    System => stop loop //don't go further

    How can i get the instance returned by Bullet(bulletAlive.At(loopindex)).key == "R" ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I found a solution by replacing the loop for with a loop foreach.

    https://www.scirra.com/tutorials/418/for-each-tutorial

    In fact it seems that in foreach loop it set the instance variable and it's not the case of loop for...

  • The loops seems working but no... i'm wrong

    anyone knows how to retrieve a specific Sprite from it's uid and make action on it?

  • Doesn't "Pick by UID" work?

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