Creating the right family object

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

    Suppose I have two families, one for normal sprites and one for normalmaps for the sprites. I'm trying to run a condition that runs for each of the sprite family object and creates a normalmap from the normal map family for each of them. However, the normal map is randomly chosen from the normalmap family. Is it possible to create a condition that picks the right normal map for the right sprite using families in the condition? Or do I have make a condition for every individual sprite to create the normal map for it?

  • There's no way to specify the object created from a family but also you don't need to make a condition for every sprite object, you could do something like create map object by name where the map you want is an instance variable on the sprite.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks, yes that's pretty good. Works when I give the normalmap name to a string variable in an already existing object.

    But what if you create both objects one after the other? The original sprite would be spawned with no instance variable string data that it can use to spawn the normal map.

  • You can set the variable on the sprite as it's created and before you spawn the map if you put the events in the correct order.

  • But if you have to put the variable in the sprite variable as it's created isn't that the same amount of work as creating the normalmap individually when the sprite is created? You have to give each object its individual normalmap variable after all..

  • Yep. You didn't mention the sprites are created in original post, you said for each sprite it creates a map.

  • Yes, I think I might find it useful to also create them automatically when I create the sprites later.

    One option of course is to have one object of every type placed in the editor (as you should do anyway since it helps construct load the objects you need in the startup) and have the string data saved in that object, so all the objects that get created after that will use that object's variable data as default. After that you can put those objects in a family "DestroyAtStart" and destroy them in layout start, and it apparently won't affect the objects' default variable data when created later on.

  • Actually I came up with a better idea...

    Since all my normalmaps are named after their parent sprite with "_Normalmap" extension in their name, I can put all the normalmapped objects into a family and then create the object by its name by using "normalmapped&"_Normalmap"" as the name. No need for string variables.

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