function, remember picked for expressions return values

This forum is currently in read-only mode.
From the Asset Store
Add this awesome sound effects to make your visual novel come to life!
  • Not sure if its me doing something wrong as i'm new to functions.

    I have multiple instances of an object, each with a private value of either blue box or red box.

    When you click on one of these instances i want to create another object based on what type of private value it has which i've clicked on.

    I thought an elegant method would be to do -

    on object clicked > create object by name (funtion. return myfuntion)

    on funtion(myfunction)

    +instance priavate variable(object type)= "blue box" > return function (BlueBoxSprite1)

    on funtion(myfunction)

    +instance priavate variable(object type)= "red box" > return function (RedBoxSprite1)

    So the function compares the private value and if its a blue box it returns the blue blue box sprites name, and same for if its red.

    but i think the problem is when calling return functions in an expression there is no option to remember or forget picked objects, like you can do if it's just an action "call function".

    Is this right or have i got things wrong?

    Thanks.

  • why even use functions for this?

    on object clicked

    (subevent) +('obj type')=blue box >>> spawn blue box

    (subevent) +('obj type')=red box >>> spawn red box

    now you have one event instead of three.

  • I simplified my problem down as an example.

    What am actually doing is much more complicated but it boils down to what i posted.

    Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Why not store the actual name of the sprite to spawn in the private variable?

    Ie. Create object by name: Object('name_to_create')

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