Help with layers

For developers using the Construct 2 Javascript SDK

Post » Wed Apr 03, 2013 2:28 am

I'm trying to automate in javascript the setting of one layer visible and the rest invisible. I can't seem to wrap my mind around how to accomplish this. Please tell me what I'm doing wrong. Here is the runtime function:
Acts.prototype.SetVisible = function (visibles, begin)
     {
          var layernow;
           for (var i; i = begin; i<= begin+100)
           {
          layernow = this.runtime.getLayerByNumber(i);
          layernow.visible = true;
               this.runtime.redraw = true;
           }     
     };

And the edittime settings:
"name":               "Contact Wizard Pro",                    // as appears in 'insert object' dialog, can be changed as long as "id" stays the same
          "id":               "ContactWizarPro",                    // this is used to identify this plugin and is saved to the project; never change it
          "version":          "1.0",                         // (float in x.y format) Plugin version - C2 shows compatibility warnings based on this
          "description":     "<functions built for Contact Wizard Pro>",
          "author":          "<your name/organisation>",
          "help url":          "<your website or a manual entry on Scirra.com>",
          "category":          "General",                    // Prefer to re-use existing categories, but you can set anything here
          "type":               "object",                    // either "world" (appears in layout and is drawn), else "object"
          "rotatable":     false,                         // only used when "type" is "world". Enables an angle property on the object.
          "flags":          pf_singleglobal | pf_appearance_aces | pf_predraw,

And the action in edit time:
AddNumberParam("Layer", "Layer to make active" ,0);
AddNumberParam("Starting Layer", "Start layer search on this layer" ,0);
AddAction(1, af_none, "Set Visible Layer", "Layers", "Set {0} to visible", "Set the working layer visible!", "SetVisible");
B
67
S
21
G
15
Posts: 701
Reputation: 15,579

Post » Wed Apr 03, 2013 2:30 am

I understand the for loop isn't formed to set the layer visible. I had it set properly but couldn't get it to work, so now I'm just trying to get any of them to be visible because it's so frustrating.
B
67
S
21
G
15
Posts: 701
Reputation: 15,579


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest