How I can destroy any instance on destroing my?

Get help using Construct 2

Post » Sun Nov 20, 2011 8:09 am

I need destroy some object when destroying my...
I use next code for it:
[code]behinstProto.onDestroy = function() {
    if (this.destroyObject) {
        this.runtime.DestroyInstance(this.destroyObject);
    }
};[/code]

but it does not work, and why:
[code]runtimeProto.DestroyInstance = function (inst)
     {
          // Add to death row to destroy later
          this.deathRow.add(inst);
     };[/code]
object is added to all the destruction, but it happens here:
[code]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--;
             }
               ...
[/code]
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:
[code]if (!this.deathRow.isEmpty())
               this.redraw = true;

          this.deathRow.clear(); // THIS!!!!!!
     };[/code]
A new instances in list was cleared with old together...

Ok... How I can destroy any instance on destroing my?
B
4
S
1
G
1
Posts: 36
Reputation: 949

Post » Sun Nov 20, 2011 5:30 pm

Ashley wrote :
[quote]This 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:

[quote]Some useful resources for javascript are:

Mozilla's Javascript Guide - https://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 - http://www.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 - http://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) - https://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][/quote]


Enough with the pluginmania already...
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Mon Nov 21, 2011 1:15 pm

In my opinion that is a microbug of C2...
B
4
S
1
G
1
Posts: 36
Reputation: 949


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 34 guests