How do I create a re-usable set of instructions?

  • Hello everyone, I'm a developer that has mostly worked with Unity and simple WebGL engines such as Phaser and I'm wondering if it's possible to create something that would be considered a "Prefab" in Unity. A prefab is basically a re-usable object that can have different settings.

    For example, I like to create idle games and a very common occurrence for me is going to be to have a bunch of elements that do the same thing. For example a basic idle function would look something like this:

    const idleObject = {
     name: 'Lemonade Stand',
     purchased: false,
     purchasePrice: 100,
     level: 1,
     modifier: 1.07,
     generates: { value: 1, modifier: 1.04, currency: Currency#type },
     ticks: 30,
     sprite: "lemonade-stand.jpg"
    };
    

    It would be nice to be able to just customize the configuration on an object like the one above and not have to worry about setting up all of the addition events in Construct such as `onTapObject::Sprite->TryToUpgradeOrPurchase` and `Every X seconds add Y Currency#Type` but as of right now I have to go in and set these all manually, which is a huge drag.

    I'm really looking forward to giving construct a try, but I would like to know how to get a little more advanced with re-usability. If I could just supply a list of data and have these items accessable for rendering automatically via some sort of template engine, that would be amazing.

    I spent my time writing out an idle-engine in javascript that does everything I want, but I was getting highly annoyed with the limited UI flexability of Phaser and wanted to try out Construct before resorting back to Unity.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • With what you’re saying about prefabs I’d say objects can be kind of thought like that. Just create multiple instances of the same object, and you’ll only ever need one set of events.

    Personally I tend to use as few object types as possible so I don’t have duplicate events if I can help it.

    I’d reccomend reading about picking in the manual. It makes a lot of things fairly easy.

    There are aspects where picking isn’t ideal, such as when created instances can be picked, or wanting to pick two separate instances indavidually, but there are strategies for that.

    Also generally you don’t need to use a list of data. Placing instances and tweaking their variables is the normal way to go about it in construct.

    I guess it depends on what you want to do.

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