Creating Multiple Instances During Runtime for Efficiency and Organisation

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • I've been using Fusion for a while now and I feel I'm fairly well adapted to it, but I've always had a nag that I've never gotten round to solving.

    My problem is with creating and editing instances of an object at runtime so as to keep the amount of objects in my workspace to a minimum. For example, I might want 6 labels in my frame, each displaying different strings, and during runtime I might want to change the 3rd label. If I'm creating and positioning the labels during runtime, I have trouble pointing only to the 3rd label and editing that one only.

    If anyone can point me in the right direction for how to go about this, it would be greatly appreciated :)

  • Basically, you need to "mark" them in some way, so that each of your instances has some "ID" that makes it unique.

    If you create objects in runtime, you can give them an ID directly upon creation:

    i.e.

    on loop "create_label"
    >>> create "label"
    >>> set "label" ID to loopindex("create_label")


    If you have your labels already created in frame editor,
    another simple solution could be:

    run this event once
    >>> spread value 0 in "ID" of label


    Both of these will assign each of them a unique "ID" from 0 to 5 (since there are 6 of them)

    then each time you want to reference a specific instance,
    you simply add a "filter" in the condition,
    say you want to address label 3:

    (your triggering action)
    +"ID" of "label" = 3

    a selection of my Fusion examples can be found Please login to see this link.

  • Ah yes, I think I've done this before in a previous project but lost all comprehension of it at some point.

    Just to clarify, the ID would be an alterable value and so this cannot be done with String objects, right? If not, I can probably find a suitable replacement in the form of Rich Edit or whatever.

    Thanks for the swift reply, that was just the pointer that I needed :)

  • Yes - sorry,
    I was talking about tagging "ID" an alterable value of the "label" object X)

    Your labels are string objects?
    You can still use them, i.e. you can store their "fixed value" as ID in a reference table,
    you could use global values for this, or an object's alterable values or a list object

    i.e. using an object's alterable values to store IDs (let's call it "my labels")

    run this event once
    >>> start foreach loop on each one of "string"

    on each one of "string"
    >>> set value foreachloopindex("string") of "my labels" to fixed value of "string"

    this will populate your first 6 alt. values of "my labels" object with fixed values of your strings

    then to pick a specific label:

    (your triggering event)
    + pick object with fixed value = (AltValN xx of "My labels")
    >>> do stuff

    where "xx" is your label number from 0 to 5

    a selection of my Fusion examples can be found Please login to see this link.

  • ehm, also consider you might have far simpler options, depending on your game / personal preferences

    i.e. if your strings are static, you could pick them by position

    (on triggering event)
    + pick all objects in a zone
    and set a zone around the string
    (this is a condition inside the "new objects" element)

    or you could make "pointers" over each label,
    like object 1 placed over string 1 and so on

    and then:

    (on triggering event)
    + object 3 overlapping string
    >>> do stuff

    will pick the string overlapped by the specific object

    a selection of my Fusion examples can be found Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!