Suggestion: Multi-Sprite Instance Variables

0 favourites
  • 7 posts
From the Asset Store
Color Variable
$4.50 USD
10% off
Easily store, modify, read and manipulate colors with Color Variables!
  • 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.

  • I?m 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.

  • 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.

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

    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?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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?

    <img src="https://dl.dropboxusercontent.com/u/10196246/Family%20variables.JPG" border="0" />

  • 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.

  • 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.

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