0 Favourites

How do I get Uid of an Sprite every time layout restarted

  • Hi , I have a restart button on game and when user clicked on that,the layout will be restarted and in this game an sprite created many times , I want to get uid of first of this sprite has been created every time layout restarted , note : some times sprites destroyed then uid of first sprite in every restart will be changed , Forgive me for my bad english

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I don't know if I understand you correct. Sorry if isn't what you want.

    If you want the first sprite of several instances of this sprite, I would use the IID not the UID. The IID is a number in ascending order number starts with 0 for the first sprite.

    You can then easily access a sprite with a definite number with the condition 'pick nth instance'.

    For example the first sprite with IID=0:

    System| Pick Sprite instance 0

  • I don't know if I understand you correct. Sorry if isn't what you want.

    If you want the first sprite of several instances of this sprite, I would use the IID not the UID. The IID is a number in ascending order number starts with 0 for the first sprite.

    You can then easily access a sprite with a definite number with the condition 'pick nth instance'.

    For example the first sprite with IID=0:

    System| Pick Sprite instance 0

    Yes your idea is correct but in this layout every 2 second that sprite is creating in top of layout and every tick it's moving to bottom of layout , after this sprite goes out of layout it will be destroyed and on the other in same time in most possible I have 2 of that in the view and iid of that spite is changed when other sprite has been destroyed (first one's iid = 0 and next one's iid will be 1 after destroying first sprite, next sprite's iid will be changed to 0 and its make my code inefficient )

  • You could have a variable that counts how many objects have been created and resets when the layout start.

    Something like:

    tempFirstSpriteCount=0

    tempFirstSpriteUID=0

    ------

    If tempFirstSpriteCount is equal to 0 -> set tempFirstSpriteUID to sprite.UID

    ------

    every 2 seconds -> create sprite

    add 1 to tempFirstSpriteCount

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