How do I pick the family from another sprite?

0 favourites
  • 13 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • I've hunted the forums, but not found what I need.

    I have a Tree sprite made of 10 sprites. A bit like this...

    F=Foliage, T=Trunk and B=base.






    The plan is, when I collide with the Trunk, the foliage shakes.

    The Foliage sprites are in a family called 'TopOfTree'

    When the player collides with the 'T'runk, I enable the Sine behaviours that are in the 'TopOfTree' family.

    How can I achieve this?

    I did add the base and trunk to the family, but only the base shakes (which shouldn't shake at all). I know I need to select all the other sprites that make up the family but I can't figure out how to.

  • This sounds like a job for containers

  • Thanks for the prompt reply, I will go look at that right now and report back in.


  • OK, I admit defeat, after another 4 hours trying containers, families, hidden placeholders I still can't figure it out :(

    At the tree trunk I added a hidden sprite so I could add it to the family/container and then shake it with the others. It triggers, but doesn't use the family sine behaviour, just its own. I'm not sure if I'm supposed to pic the family sprites but not sure how to.

    (In case someone asks, I can't post the project since it has licensed material in it.) I might try and put together another sample however.

  • Don't use families and containers, just containers. You can say on collision with trunk, move the foliage, and it'll move the foliage that is in the container with the trunk you touched. If you try and pick the foliage as a family it'll start picking every foliage.

  • Got it, thank you.

    Removed the families.

    Added all the tree sprites to a container on the bottom of the tree.

    On Collision with the tree bottom.

    Enable sine on sprite1

    Enable sine on sprite2

    Enable sine on sprite3... etc


  • OK, ran into a snag

    It all looks fine in the layout editor, but when I run it, everything goes to hell.

    The left pic is layout, the right is runtime.

    Other than the containers, I don't do any sprite placement whatsoever.


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • As an addendum weird one, in layout mode the pieces are selected all over the place.

    I even removed all the other trees, created the container on one, then recreated the trees with the same results.

  • OK, I think some of this is a bug. I created a sample project and it corrupts the sprites as soon as I use an instance sprite.

    I'll file it as a bug and see what happens.

    Here's the sample

  • You can only have one instance of each object per container so it's creating the missing instances for two more containers. You won't be able to use Foliage 2 twice in the same tree for example.

  • OK, thanks again for your input.

    It's a pernickety little beast ain't it! I also found that if you have a sprite in the container that you haven't used, you also get unpredictable results...

    Lessons learned!

  • graham-s

    an object that is a container will automatically create all the things it contains at runtime - so even if you only place some on the layout, the rest will get created for you when the layout starts running.

    A family is what you want. The way I would do it is create an instance variable on the family so you can associate foliage with a tree base.

    I made a sample you can get here:

  • AllanR, Thank you - I will check it out.

    I always find it ironic that I can rapidly move through development and hit a brick wall on occasion! Luckily its folks on these forums that at least get me going again.

    Thanks for the project too, appreciate the time and effort!


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