Suggestion: Multi-Sprite Instance Variables

Discussion and feedback on Construct 2

Post » Wed May 22, 2013 1:10 pm

As far as I'm aware, if we want an instance variable on 30 sprites, we have to go in to each sprite to create it....even if the variables all have the same name (eg TchID).

There are family instance variables, but they're not quite the same thing.

If possible, it would be great if we could select multiple sprites, right click them and specify an instance variable that will become specific to each of the 30 sprites.
B
19
S
3
G
2
Posts: 212
Reputation: 4,011

Post » Wed May 22, 2013 2:35 pm

Im doing it like that:

-> add an family call it however you want
-> add the sprites you want to set the instance variable
-> Add instance variable to the family
-> delete the family

Works fine and there is no difference between creating them manually.
B
15
S
6
G
6
Posts: 512
Reputation: 5,550

Post » Wed May 22, 2013 2:45 pm

I just tried that in release 130 and it doesn't work. The family variable isn't visible at the sprite level. Maybe there was a change since the version you were using, but I'd settle for that work around.
B
19
S
3
G
2
Posts: 212
Reputation: 4,011

Post » Wed May 22, 2013 4:54 pm

[QUOTE=kenhes]There are family instance variables, but they're not quite the same thing.[/QUOTE]

They function the same as far as I know. A family instance variable sounds like the ideal solution to the problem you described. Do you have a specific scenario where a family instance variable would not be a viable option?
B
44
S
13
G
7
Posts: 338
Reputation: 10,389

Post » Wed May 22, 2013 5:50 pm

I just tried it and couldn't get it to work. Here's a snippet of the code that is applied to every member of the would be family. Perhaps there's a way to change to code to make it work?

B
19
S
3
G
2
Posts: 212
Reputation: 4,011

Post » Wed May 22, 2013 7:31 pm

The issue is rather with your code.
The touch.XforID/YForID will have a value only when you are touching (so should rather happen in a "On touched" event for example, not be delayed to another event).
Also it's expecting a "Layer" parameter which isn't available in what you show there.

Prefer sharing a full capx for investigation, but as far as I can tell, the issue is with your code, not with a C2 feature.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Wed May 22, 2013 8:10 pm

When I move the touch.XforID/YForID to the On touched event, the sprite moves to 0,0 when I move it.

It works as I have it so I won't disturb it but I agree, the issue could be caused by the code.
B
19
S
3
G
2
Posts: 212
Reputation: 4,011


Return to Construct 2 General

Who is online

Users browsing this forum: Yahoo [Bot], zenox98 and 15 guests