Draw onto a specific layer

Alexin

  • *
  • Posts: 3127
The article is available under Coding / API.

Regarding the snippets of code, the tab size should be bigger and it could use an horizontal scrollbar.
"Find the fun"
alexin@stencyl.com

Jon

  • *
  • Posts: 17524
The links to scenescript mentions link to the API index but not the specific class page.

Alexin

  • *
  • Posts: 3127
Oh right, I forgot to ask about this. I don't know how to obtain the exact URL. The browser's address bar shows always the same URL. Feel free to edit the article if you know how to get the correct URL (and let me know).
"Find the fun"
alexin@stencyl.com

Greg

  • *
  • Posts: 1259
If you click on the "No Frames" link at the top, it should show the full URL -

http://api.stencyl.com/as3/stencyl/api/engine/behavior/SceneScript.html

Alexin

  • *
  • Posts: 3127
Thank you, Greg.
I'm going to edit the article.
"Find the fun"
alexin@stencyl.com

MrDumle

  • Posts: 116
Sorry to bring this up again. Just wondering where how to use this script in DM mode.

coleislazy

  • *
  • Posts: 2607
It is trickier in Design Mode. You have to use some code and "trick" SW into inserting an extra function.

In the example below, I use a closing } to make SW think the "when drawing" function was done, then inserted Alexin's function below it. The explanation for how this function works is here. SW will automatically put another } at the end of the wrapper, so I had to omit the one from the example. I also broke the lines up in the screenshot so they could be read. You probably don't want to do that when you actually use this.

MrDumle

  • Posts: 116
That is very helpful, thank you. It feels like that will come in handy in the future.

Quote
" I also broke the lines up in the screenshot so they could be read. "

I guess you mean that you used two code blocks when you could have used one, am I right?

coleislazy

  • *
  • Posts: 2607
No, I mean that I broke up the function definition and the drawString arugment onto two lines each so that it wouldn't be cut off in the screen shot (since the box does not resize).

But, yes, I could have simply used one code block.

MrDumle

  • Posts: 116
oh, of course, how stupid of me.