Reference two sprites of the same type at once.

Get help using Construct 2

Post » Sat Nov 26, 2011 5:30 am

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.jumprock2011-11-26 05:30:53
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Post » Sat Nov 26, 2011 7:25 am

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 helpsvtrix2011-11-26 07:26:50
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Sat Nov 26, 2011 9:21 am

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.jumprock2011-11-26 09:23:07
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Post » Sat Nov 26, 2011 9:32 am

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
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028


Return to How do I....?

Who is online

Users browsing this forum: jeffige and 1 guest