OnPropertyChanged (Construct 3 SDK)

0 favourites
  • 2 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • Hello everyone.

    How to check, if property has been changed in the Construct editor, and if the value of the changed property is less than 0, then change the value of the changed property to 0.

    For example, in the Array plugin, in the edittime.js, there are the following functions for this:

    How do I do this in the Construct 3 SDK?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • [SOLVED]

    All you need to do is write the following line in instance.js/OnPropertyChanged:

    ("ONE" === id) && TWO > value && THREE.SetPropertyValue("ONE", FOUR);
    

    Where,

    ONE - property name (from plugin/behavior.js);

    TWO - value to compare (for example, zero);

    THERE - this._inst - for plugins, this._behaviorInstance - for behaviors;

    FOUR - value to set (for example, zero);

    If you have several properties (for example, fade in time, wait time, fade out time) that need to be compared and set to 0, then you can write like this (taken from C3Runtime version of Fader behavior):

    ("fade-in-time" === id || "wait-time" === id || "fade-out-time" === id) && 0 > value && this._behaviorInstance.SetPropertyValue(id, 0);
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)