Minimal code to draw nothing

For developers using the Construct 2 Javascript SDK

Post » Fri Jan 27, 2017 6:06 pm

Hello,
What's the minimal code to put in the runtime drawing function of a plugin:
instanceProto.draw = function(ctx, glmode){}
and in instanceProto.drawGL = function(glw){}
To draw nothing.
If I put nothing, I get error messages.
Does any of you guys have an example ?
I would really appreciate it. Thanks.
B
20
S
9
G
3
Posts: 41
Reputation: 3,126

Post » Fri Jan 27, 2017 6:14 pm

I have several plugins that do this:
Code: Select all
   // only called if a layout object - draw to a canvas 2D context
   instanceProto.draw = function(ctx)
   {
   };
   
   // only called if a layout object in WebGL mode - draw to the WebGL context
   // 'glw' is not a WebGL context, it's a wrapper - you can find its methods in GLWrap.js in the install
   // directory or just copy what other plugins do.
   instanceProto.drawGL = function (glw)
   {
   };
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Fri Jan 27, 2017 6:39 pm

Thanks for the quick reply.
That's what I did, but I got a message error:
Image
B
20
S
9
G
3
Posts: 41
Reputation: 3,126

Post » Fri Jan 27, 2017 7:07 pm

What does your GetPluginSettings section from the edittime.js look like. Sounds like a mismatch.
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Fri Jan 27, 2017 7:24 pm

It looks like this:

Code: Select all
function GetPluginSettings()
{
   return {
      "name":         "ListModel",
      "id":         "aekiro_listmodel",
      "version":      "1.0",           
      "description":   "Stores and manipulate an Array of simple non-nested hashtables (aka dictionnaries).To be used as a model for a listview for example.",
      "author":      "AekiroStudio",
      "help url":      "https://later.com",
      "category":      "Data & Storage",
      "type":         "world",
      "rotatable":   false,
      "flags":      0
   };
};

I also tried the flag: pf_position_aces | pf_size_aces | pf_angle_aces | pf_appearance_aces | pf_zorder_aces | pf_effects
but I still get the same error.

Btw, I know that ("type" : object) is more appropriate for a data structure, but I went with ("type" : world) because I need to be able to create, in the editor, multiple instances (by copy/paste) of a same type. you can't do that with a plugin of type "object" like an array, you can only clone it, which create a new type. I hope I was clear.
B
20
S
9
G
3
Posts: 41
Reputation: 3,126

Post » Fri Jan 27, 2017 7:48 pm

I don't know. There's not enough here to go on. Can you post the plugin? One of my data-only plugins is here:
plugin-smart-random_t163624
Edit: I think you do need 'object'
Edit: you can call Create, to create new instances of 'object'
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Fri Jan 27, 2017 8:18 pm

Yeah, I think I just need to go with the "object" type and let the user know that they need to programmatically create the instance.
Thanks so much for your time.
B
20
S
9
G
3
Posts: 41
Reputation: 3,126


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests