How to define what member of family to create

0 favourites
  • 6 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hi.

    It it possible to create a copy of a certain object from family at runtime, say, by UID?

    Trying to make a kind of "gallery" application for intera?tive kiosk. All paintings are stored as Sprite objects, picked together in family "Paintings", with their properties (author, genre, material, physical size, etc...) saved as family local variables. Pictures are quite small (the larger versions are loaded dynamically at runtime as the are needed), so they are all loaded at startup as global objects, forming a kind of database. The problem is, when it comes to showing some of them, I have to operate on source objects, so it's not possible to have, say, a pair of same pictures on-screen at the same time (to have a row of miniatures, showing one of them at full size, for example), and when they are not needed I have to hide them again. It would be nice to make copies, operate on them and then dispose of them, but when I use "Create oblect "Paintings" it creates a random member, and looks like there is no way to control that.

    Is there any solution or walkaround? Creating a long list of conditions and writing a uniqe "create" action for each member won't work, 'cause there are 300+ objects in family and number tends to grow.

  • Only with the help of rex_nickname plugin.

  • To 99Instances2Go:

    Seems like it does the same thing... What did I do:

    1. During initialization process: "For each <myFamilyName> -> Rex_nickname | Assign nickname <someUniqueString> to <myFamilyName>"

    2. When certain object is needed: "Rex_nickname | Create <sertainUniqueString> at (X,Y) on layer N"

    And it creates a random object from family, like if I used standard "System | CreateObject" approach.

    Did I do something wrong?

  • I have a different Idea, however, you might not like it just make one object called painting or something like that and then make an animation for each painting by name and you could load your paintings using an instance variable on your base object for instance if I added a animation called "pretty" And I had an instance variable called something like "picture to show" on a function or on created have it set the animation to that variable.

    If you want to go further you can set up an array on start called master painting list or something which will hold all of your animations names and possibly a ID-Number If you wanted your paintings numbered. All you would need is a for loop to go through that array and find the ID or the number in the array depending on how your spawning them.

    This way is a little outside the box to fix your problem I've used it for things like spell icons and inventory slots it should work for a gallery application but you have to re-code everything around that one object or make it the only object in your family.

    If you want to talk to me about this just private message me or reply.

    Anyways good luck with your project Have a nice day

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Like this: ... k8wejB6Yjg

    I should have directed you to the forum entry. Deeply sorry, expected you to do the research.


  • To 99Instances2Go:

    Thanks a lot! Honestly, was too tired to do the research!)) Didn't even notice the rex_bnickname behavior 'till tried to load your sample project, and it seems impossible to make things work without it. The thing is when I assign a nickname inside the "for each" loop via family (assigning, say, UID as a nickname), it is probably somehow associated with family object, so when I try to create a member by nickname, it is created randomly, as if it was created via family. However, assigning behaviour with "mode" set to "SID" solves the problem! Thank you!

    To Brandon12hummer:

    Thank you too for your reply. I thought of using this "animation" trick, however, it wouldn't fit for some reasons. Not even because there will be several hundreds frames of animation (taken as miniatures they are quite small and quick to load). But at some point (when user touches a miniature) a larger version of picture has to be loaded, end even a larger one if user decides to zoom it. And as far as i know there's no way to replace one particular frame at runtime, especially when sizes of frames differ so much (some hi-res versions are 5000+ pixels wide). However, the idea is good for a fixed number of comparable images, so i may use it for something else, thank you anyway!

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