Pin one sprite to another of the same type

Get help using Construct 2

Post » Sun Nov 27, 2011 12:22 am

Hi, an answer to this question might solve a few problems for me.

How do I Pin one sprite to another of the same type at runtime? (via the Pin command).

As far as I've been able to tell you can't reference two different sprites of the same type at the same time, so my_sprite(1) can't be pinned to my_sprite(2). I also don't think you can hold types other than Boolean, Number or String in a local/global variable, so that approach wouldn't work.

Any confirmation/clarification about this would be much appreciated!
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Post » Sun Nov 27, 2011 5:15 am

Add Pin behavior to my_sprite(1), go to Events sheet and set action for my_sprite(1) "pin to object" and select my_sprite(2).
B
4
S
1
G
1
Posts: 36
Reputation: 949

Post » Sun Nov 27, 2011 7:05 am

Hi JohnJ, thanks for taking the time to reply but I think your example illustrates linking a sprite of one type to a sprite of a different type. What I am talking about would be like trying to pin one instance of Sprite2 (a ghost) to another instance of Sprite2 (another ghost).jumprock2011-11-27 07:05:33
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Post » Sun Nov 27, 2011 7:18 am

i tried it and i think you right, i doesnt work, i think the behavior doesn't take the picked objects into account for this to work behavior should be modified
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Sun Nov 27, 2011 10:09 am

jumprock, ok, I see now. And for what you pin one Sprite2 to another Sprite2? Any control or change params will be work for both... Make different types?
Or you can create an example, share it and tell which result do you want.
B
4
S
1
G
1
Posts: 36
Reputation: 949

Post » Sun Nov 27, 2011 10:24 am

Hi JohnJ, In this situation finding a workaround isn't really the focus, it's just serving to highlight the fact that references to two or more different instances of a single type can never exist in the same event action at the same time (and hence they can never have direct access to each other).

Pinning was just an example (one that I currently am dealing with) of functionality that can't be used because of this.jumprock2011-11-27 10:25:33
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Post » Sun Nov 27, 2011 10:39 pm

Not possible? (referencing two instances of the same type in the one action)jumprock2011-11-27 22:39:52
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Post » Sun Nov 27, 2011 10:51 pm

ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Sun Nov 27, 2011 11:07 pm

If there are two Sprite instances their values can be accessed with Sprite(n).

Ex.
Text: Set Text to Sprite(0).X + Sprite(1).X

In the case of your question, it will be simple to do when families are implemented, but at this point you'll have to resort to events instead of using the pin behavior as a workaround.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Sun Nov 27, 2011 11:25 pm

Hi R0J0hound, I'm not sure that would work.

Just say your sprite type was called Cat, as I understand it you could pick a first instance by it's index (though probably seleting by UID is going to be more use) but once you picked a second instance the reference to Cat in your actions section would be to the last selected instance.

So you could never have an action that said something like:

Cat(2).my_instance_variable = Cat(1).my_instance_variable.

Instead all you can do is:

Cat.my_instance_variable = Cat.my_instance_variable

where Cat refers to the last referenced instance. As far as I can tell actions only allow you to reference a single, currently selected instance of any particular type at a time.

Not sure if I have a correct understanding or maybe didn't comprehend exactly what you were saying, but to me it seems impossible without a middle man event/action to store values in a proxy variable. And the native Pin functionality seems impossible to implement at all between two instances of the same type.


Will be interested to see families... can you explain the concept at all?jumprock2011-11-27 23:26:58
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Next

Return to How do I....?

Who is online

Users browsing this forum: armaldio, plinkie and 17 guests