Reference two sprites of the same type at once.

0 favourites
  • 4 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Hello, I have a sprite type for standard non player controlled (npc) sprites and at any one time there are a handful of these on screen.

    I am doing a loop through this sprite type and within each sprite I've saved the UID of a second sprite (of the same type) in a variable. I'll use this UID to reference the second sprite by way of Pick Instance by UID.

    The problem is that I am unable to reference two instances of the same sprite type at once in order to achieve something like the following:

    npc_sprite(1).width = npc_sprite(2).width

    I've put the (1) and (2) in there to demonstrate that these are different instances of the same sprite type, named npc_sprite.

    Hope what I'm trying to achieve makes sense, is there a way to do this?

    P.S. I am only using width as an example as the property I am trying to reference is actually a custom variable.

  • you will have to give the first.uid to the second sprite in a variable(example: nr) at creation and then

    for each npc_sprite

    system compare:

    npcsprite.uid = npcsprite.nr

    set alpha to 50 for example

    hope this helps

  • I think I understand what you're suggesting and I appreciate the idea - will try it out.

    Would be great if you didn't need to take such a round about process to achieve something like this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • well it really depends of what you want to achieve, not 100% sure here, there could be another easier way, also there are a few things still missing in construct2 that are in classic, families and containers > when they are implemented will make does things far easier

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