Issues with instance UIDs for dynamically created objects

Get help using Construct 2

Post » Mon Oct 06, 2014 8:50 pm

Hi!

I've got some issues in my program. The idea is that when you hold the key "c" and click on two nodes the nodes will be connected by a black "wire". And if you press "a" you can create more nodes. Everything is shown in the video below. It all works well for the objects created in the editor. But when adding new objects by pressing a and clicking a free spot the connection feature won't work anymore. See the video here: http://youtu.be/sztt1364HlU

Here is my .capx file as well: http://www.mediafire.com/download/q6q5w ... oblem.capx
I will be very thankful if someone can tell me what I've done wrong. Perhaps it's just something silly that I've missed. :)

The positioning of the wire object is decided by the nodes UIDs as you'll see in the code. But as it all works with objects created before running the program I don't know what's wrong really.

Some of the logic in the program is a bit wierdly implemented but it's a quite small program after all so I think you'll be able to see what's going on.
B
8
S
3
G
2
Posts: 45
Reputation: 2,193

Post » Mon Oct 06, 2014 10:05 pm

The Sprite(0) expression references the sprite with IID 0, not UID. It's just a coincidence that the sprites on the layout have UIDs that line up with their IIDs so the events work for them.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Tue Oct 07, 2014 8:14 am

Oh.. Well that was a silly problem.. Thank you! But are there any similar way to select instances with a specific UID? As I'm using two UIDs in the same event I can't "pick by UID".

I got it working by first getting the UIDs and then from the UIDs I selected the correc IIDs to use. The issue then is that if you delete a node the IIDs will change. Which means I would not too run a routine to update all connections to use the right IIDs. So it would be more neat if you could use the UIDs directly in an expression.
B
8
S
3
G
2
Posts: 45
Reputation: 2,193

Post » Tue Oct 07, 2014 1:01 pm

You can add the Node to a family "NodeFamily" and then pick Node by UID for the first one and pick NodeFamily by UID for the second one. Then you can create a wire at Node.X, Node.Y and set it's angle towards NodeFamily.X, NodeFamily.Y.

The other way to do it would be to pick one Node by UID first and store it's x,y values in local variables. Then pick the second node and do your thing.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Sat Nov 15, 2014 11:55 am

Thank you ramones, sorry for my late reply but I think you're idea will work just fine.
B
8
S
3
G
2
Posts: 45
Reputation: 2,193


Return to How do I....?

Who is online

Users browsing this forum: marcinkowski, plinkie, zenox98 and 20 guests