0 Favourites

How I can destroy any instance on destroing my?

  • I need destroy some object when destroying my...

    I use next code for it:

    behinstProto.onDestroy = function() {
        if (this.destroyObject) {
            this.runtime.DestroyInstance(this.destroyObject);
        }
    };

    but it does not work, and why:

    runtimeProto.DestroyInstance = function (inst)
         {
              // Add to death row to destroy later
              this.deathRow.add(inst);
         };

    object is added to all the destruction, but it happens here:

    runtimeProto.ClearDeathRow = function ()
         {
                    .....
              var arr = this.deathRow.valuesRef();     // get array of items from set
    
              for (i = 0, leni = arr.length; i < leni; i++)
              {
                            ...
    
                   // Remove from all behavior-plugin's instances
                   if (inst.behavior_insts)
                   {
                        for (j = 0, lenj = inst.behavior_insts.length; j < lenj; j++)
                        {
                             binst = inst.behavior_insts[j];
                             
                             if (binst.onDestroy)
                                  binst.onDestroy();   ///// THIS!!!!!!!!!!
                                  
                             binst.behavior.my_instances.remove(inst);
                        }
                   }
    
                            ...
    
                   if (inst.onDestroy)
                        inst.onDestroy();  /// OR THIS!!!!!!
                        
                   this.objectcount--;
                 }
                    ...
    

    arr - is array of old list of destroying instances, new added instance located in this.deathRow at now!

    After arr-loop ("for") we have next code:

    if (!this.deathRow.isEmpty())
                   this.redraw = true;
    
              this.deathRow.clear(); // THIS!!!!!!
         };

    A new instances in list was cleared with old together...

    Ok... How I can destroy any instance on destroing my?

  • Ashley wrote :

    his is a basic Javascript language question - it's best not to ask about the Javascript language itself in the forum, because there are much better places to learn Javascript on the web. From the SDK docs:

    ome useful resources for javascript are:

    >

    > Mozilla's Javascript Guide - developer.mozilla.org/en/JavaScript/Guide

    > A complete guide to javascript. This might be a good starting point if you are new to programming.

    >

    > StackOverflow - stackoverflow.com

    > An excellent Q&A website. Also a good place to search to see if your question has already been asked and answered.

    >

    > Javascript Garden - bonsaiden.github.com/JavaScript-Garden

    > Guide to the unusual parts of javascript. Very useful if you have experience with a different programming language but are new to javascript.

    >

    > Mozilla Developer Network (MDN) - developer.mozilla.org

    > An excellent reference for HTML, javascript, and more. A very useful place to look up features for the browser side of the plugin./quote]

    Enough with the pluginmania already...

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • In my opinion that is a microbug of C2...

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