Draw onto a specific layer

Alexin

  • *
  • Posts: 3127
I'm making a demo for several light source behaviors. I want to include navigation buttons, descriptions and other things, which should always be visible and accessible.
The problem is that the Light Source behaviors paint the screen all black, masking any element underneath. Since the behaviors are for scenes, the first solution is to make them for actors, so the painting can be done on the actor's layer. However, it doesn't make much sense and the user can't pick an actor from a scene. It's also awkward to create a dummy actor just to delegate the painting.

Jon, would you mind if add a drawing method to SceneScript, that get's called when a layer is drawn? That method would be similar to the current one, but adds a parameter to tell which layer is being painted.

Several times users had to workaround this and it would make some behaviors more robust (no need for extra actors and behaviors).
"Find the fun"
alexin@stencyl.com

Jon

  • *
  • Posts: 17523
Sure, you can add a hook method for this provided that you document it in the code for the AS Doc and write up a stub document for Stencylpedia.

Alexin

  • *
  • Posts: 3127
Sure! Should I add an empty implementation in the template, or is it too specific?
"Find the fun"
alexin@stencyl.com

Rhys

  • Posts: 1046
A block to set this would be useful too.

Luyren

  • *
  • Posts: 2717
A block would be good. I think the best would be a block like the "draw on screen space" or "draw on actor space", so we wouldn't have to modify the existing drawing blocks.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

Alexin

  • *
  • Posts: 3127
The method doesCustomDrawing() isn't required anymore. Is that on purpose? I see it related to postDraw and preDraw, nothing else.
"Find the fun"
alexin@stencyl.com

Jon

  • *
  • Posts: 17523
I'm not 100% sure, but I think it still applies. Its purpose is to "register" a behavior with the system to make it receive calls to its pre and post draw methods, so there's no overhead of making those calls for behaviors that don't draw.

Jon

  • *
  • Posts: 17523
Sure! Should I add an empty implementation in the template, or is it too specific?

In the ASDoc? Not a bad idea at all to do that.

Alexin

  • *
  • Posts: 3127
Well, it isn't required anymore. My actors can draw without enabling custom drawing.

Sure! Should I add an empty implementation in the template, or is it too specific?

In the ASDoc? Not a bad idea at all to do that.
I was talking about the template used to create new CM behaviors.
"Find the fun"
alexin@stencyl.com

Jon-iPad

  • *
  • Posts: 166
In code mode or DM? It's implicitly inserted in DM.

Alexin

  • *
  • Posts: 3127
Code Mode.

I added a check and I'm about to test the changes.
"Find the fun"
alexin@stencyl.com

Alexin

  • *
  • Posts: 3127
I just checked in the support to draw onto a specific layer. I also fixed the code so doesCustomDrawing is required.

(Behaviors were created as drawable from the start. Now, they don't and a behavior is required to specifically enable custom drawing.)

I have tested these changes, but let me know if something is amiss.
"Find the fun"
alexin@stencyl.com

Jon

  • *
  • Posts: 17523
I will update engine.swc on the server, so folks can pick this up through a reupgrade.

Jon

  • *
  • Posts: 17523
engine.swc updated. Reupgrade SW to get it.

Alexin

  • *
  • Posts: 3127
I didn't forget to write the article. I'll do it tonight or tomorrow.
"Find the fun"
alexin@stencyl.com