How do I get spritename from its UID

0 favourites
  • 8 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
  • Hi,

    I have created a function to which I am passing sprite's UID as parameter. In the function, I want to access sprite again with the help of passed UID. Will I be able to access it?.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • https://www.scirra.com/manual/130/common-features

    Read under Unique IDs (UIDs). Pick by unique ID

  • Thanks....Let me clarify...Suppose there are two sprites. There is one function who does the work of resizing the sprites. What I want to do actually do is I want to resize first sprite when I pass UID of first sprite and want to resize second sprite when I pass UID of second sprite. To be more concised, I want one function to work with two different sprites.....Is it possible??

  • More info, ok So when you say 2 Sprites, I assume you mean 2 different object types, not 2 instances of 1 object type (Sprite) otherwise it would be no more difficult than 1. You will have to put it them in a Family then you can pick Family by unique ID.

    edit: I'm ignoring that your topic title says that you want to get 'spritename' because that's not what you've asked in your questions.

  • Thanks....There are two different sprites.......and I am passing UID of one sprite to the function.....Like....

    resize(sprite1.UID)...............(Function call)

    resize(sprite1.UID)..............(Function Definition)

    {

    Sprite1------set size to (420,630);

    }

    Is it possible in construct2? If I pass sprite2 to the same function will it work?....If you did this, would you please share .capx file?

  • Yes. Picking an object by UID is pretty fundamental and the link I posted above has the details.

    edit: the yes is for the first part of the question. The second part is 'no', but see below for how to do it.

    If you have two different sprite types then you'll need to add them to a Family, then pick Family by UID in the function.

    If I get a sec I'll do a capx.

    edit: hope this helps. You'll see if you select Sprite1, then try and change it's size using ResizeASprite2() function, it won't resize (same with Sprite2 and ResizeASprite1()). If you use the ResizeSpriteByFamily() function you can click either type and it will still work.

    [attachment=0:1zb92xpo][/attachment:1zb92xpo]

    edit: tiny update to capx so you can keep resizing until the cows come home

  • Great!!!!!.....Thanks a ton....

  • Great!!!!!.....Thanks a ton....

    welcome

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