Is there any way to spawn each item of a family?

Not favoritedFavorited Favorited 0 favourites
  • 8 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Pretty much, I want some line of code that would be able to spawn 1 of each object in a family without it already being in the layout (it's 15k object in the family once I'm done, so no, not one at a time). The way that I'm currently doing stuff is taking up way too much space and it would be a lot easier than having each object preloaded in the layout.

    Tagged:

  • 15k object in the family

    That's a bit insane. I would definitely combine these objects into sprites (as separate animations).

    Your best bet is to make a list of all family objects - you can get it from the family.json file if you save the project as a folder. Then create each object from the list using "Create by name" action.

    Or you can do this with Javascript:

    const f = runtime.objects.FamilyName;
    for (const t of f.getAllObjectTypes()) {
     runtime.objects[t.name].createInstance(layer,x,y);
    }
    
  • > 15k object in the family

    That's a bit insane. I would definitely combine these objects into sprites (as separate animations).

    It's fine for my understanding of how to make stuff. They're all separate items but share a family. I need them to all hold individual variables and dictionary info per item, so I'd have no idea how to do that with individual frames. It's for a trading card game that already exists and has around 15k cards. That's why I said when it's done.

    Also sorry, was that you saying how to do it? I'd understand a lot easier with the event sheet, I'm more of a visual learner.

  • I need them to all hold individual variables and dictionary info per item, so I'd have no idea how to do that with individual frames.

    You should store all that info in one or several arrays/jsons. It's MUCH easier than manually enter it into instance variables. That's what we do in our game - the array holds about 300 cards:

    Also sorry, was that you saying how to do it? I'd understand a lot easier with the event sheet, I'm more of a visual learner.

    Which option? Creating from the list of objects, or using scripting?

  • Which option? Creating from the list of objects, or using scripting?

    Oh, I thought you were trying to say how I could spawn each item anyways. Also I'm already like one-thousand in, either way I'm a bit too far for me to just delete everything.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you need to summon family members all at once straightforward approach would be looping through ObjectType of that family.

    Example: dropbox.com/scl/fi/07wqkp6cujsyz36nrudd2/summon_family_at-once.c3p

  • If you need to summon family members all at once straightforward approach would be looping through ObjectType of that family.

    Example: dropbox.com/scl/fi/07wqkp6cujsyz36nrudd2/summon_family_at-once.c3p

    But this will only affect family members who are already on the platform.

    - needs to be created, not just listed.

    Of the available options, I also support a list of members in an array or dictionary where we can go through each name and create it.

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