JohnJ's Recent Forum Activity

  • why only chrome? I use only Opera & Firefox...

  • nice idea! ok, and how do you want to save pictures? svg?

  • In my opinion that is a microbug of C2...

  • 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?

  • Some hint you can read in Construct 2, when click on property "Drift recover", read in bottom left corner short description of selected property.

  • try to use this plugin

    or see it as example...

  • Oops, I did not s?? that this plugin has already made ??himself and exactly the same and called it "Spaceship" too! I based my behavior on behavior "car". Plugin by Fimbul better than mine, in my opinion, although it has bugs in response to "On solid collision"

  • Kyatric: thanks, many interesting information!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I thought that construct2 does not work with .capx files...

  • One Way Door - it's cool idea! this is a more abstract concept

  • Thank's! I do it! :) Now I have a weapon on any created object by behavior... But now I need to finish the behavior. Thank you for help!

    in case you can simplify things, here's what I got:

    var plugin = this.type.objtype.instances[0];
    var image_point = {
        x: plugin.getImagePoint(this.bullet_point, true),
        y: plugin.getImagePoint(this.bullet_point, false)
    }
    var new_bullet_inst = this.runtime.createInstance(
        this.runtime.types_by_index[2], 
        this.runtime.getLayerByNumber(this.bullet_layer), 
        image_point.x, 
        image_point.y
    );
    new_bullet_inst.angle = this.angle;
    new_bullet_inst.set_bbox_changed();
    

    I can't find a function for replace this.runtime.types_by_index[2] to this.runtime.getTypeByName('Bullet'). If I wanted to create this function, where should I do this? change the program files do not want to, as the upgrade version will be updated ...

    And what about properties types. I need a ept_keyb and ept_instance types :) Now I use float and text instead of it, but it is not usability...

    And... How can I require that my behavior can only be used for sprites or other plugins that have method "getImagePoint" at "edittime"?

  • Hello, I try create a behavior "Weapon".

    Now I can't create a Instance of bullet in my plugin.

    My actions:

    1. Create a bullet on project.

    2. Create a "tank" with weapon.

    3. Add my behavior "Weapon" to the "tank".

    4. On the "space" key down I make a shoot from weapon by bullet from step 1.

    But for it I must create a new bullet from my behavior script. I saw in Events sheet, that my "tank" as Sprite can use Spawn function for create new Instance Bullet. From script it looks terrible in my performance:

    this.type.objtype.plugin.acts.Spawn.call(
        this.type.objtype.instances[0], 
        this.runtime.types_by_index[2],
        this.runtime.getLayerByNumber(this.bullet_layer),
        1
    );

    And of course, it does not work. Causes an error somewhere in eventg.js, as shown by firebug:

    evinfo.current_event is null

    return evinfo.current_event.actions[evinfo.actindex];    eveng.js (line 1576)

    I think it should be way easier and more beautiful, but I have not found anywhere else.

    Help me, please.

    Raw current variant of plugin you can download from onlinedisk.ru/file/772010

JohnJ's avatar

JohnJ

Member since 17 Nov, 2011

None one is following JohnJ yet!

Trophy Case

  • 13-Year Club
  • Email Verified

Progress

14/44
How to earn trophies