Choose which layout new instances are created from

0 favourites
  • 6 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi all,

    I have a layout called 'Placeholder' where I stash assets with default values for when they're created dynamically ingame.

    My problem occurs when I copy that asset into a layout and change the default values. Now ingame the default values have changed from the one in the 'Placeholder' layout.

    What is the criteria to which Construct 2 chooses a lyout to create an asset from?

  • I would keep the default stats in the placeholder layout (if they are kinda important to the gameplay) and then set any stats on start of the other layouts. As far as I can tell if you update stats or add behaviours to a copied version it will update it for all instances.

  • As far as I can tell when creating an object at runtime the first instance you inserted at edit time is used to the object's created state. It can be a problem to find that instance unless you put it on an asset layout first. I usually just manually set the object state manually when creating at runtime though and completely disregard the edit time values.   It would be useful if there was a way at edit time to pick the initial object or even make a certain instance the reference for default values.

  • R0J0hound Thanks for the clarification.

    It would be useful if there was a way at edit time to pick the initial object or even make a certain instance the reference for default values.

    Indeed, that would fix my issue :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The most sensible thing to do IMO is to create an object then immediately set all its properties with actions. I don't see any reason for the engine to pick one template instance over another, unless we implement a special "prototype" instance.

  • Ashley this makes sense, and I agree for most situations.

    My use case is having a text object with a standard text size that is used throughout the game. This means when I dynamically create any text in game it matches the predefined size, rather than setting parameters for every created instance.

    There are a number of alternative solutions though, with global variables or functions to solve the problem too.

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