Z-Index Extension [Now part of Stencyl 3.2+]

captaincomic

  • *
  • Posts: 6109
Starting with Stencyl 3.1 (or build 7160) these blocks are in the core palette under Actor->Draw->Layer. The extension is not needed anymore.

Z-Index Extension
This extension should work on every platform. I have only tested it on Flash, if you any issues with it let me know.

This extension provides blocks to change the drawing order (z-index) of actors within a layer.
This is useful if you need fine grained control over the drawing order of your actors, so you don't need to create a layer for each actor.

Download this Extension. Use Stencyl 3.1 instead. (If you have to use 3.0 and want to use this extension, drop me a message. Although I would really recommend to use 3.1.)

move actor [  ] [to the bottom/to the top/down/up] within the layer

These blocks change the drawing order of the actor within a layer.

z-index of actor [  ] within the layer

This block returns the current z-index of the actor.  The z-index is an integer in the range of 0 to <number of actors within the layer>-1. A z-index of 0 means that the actor is at the bottom.
This block can be useful to check whether the actor is in front or in the back of another actor: if the z-index of an actor is larger than the z-index of another actor, it is in front of the other actor.

number of actors within the same layer as [  ]

Returns the total number of actors within the same layer as the specified actor. Can be useful to check if an actor is at the top of the layer. An actor is drawn on top of the layer if the z-index of an actor is equal to the number of actors in the layer minus one.

Version History
1.0: Initial Version
1.1: Combined the "move" blocks to a single block with dropdown. Added the "number of actors" block.

« Last Edit: February 03, 2015, 08:35:55 pm by Jon »

Hectate

  • *
  • Posts: 4643
Noted.

* Hectate whistles nonchalantly...
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

captaincomic

  • *
  • Posts: 6109
A small update:
1.1: Combined the "move" blocks to a single block with dropdown. Added the "number of actors" block.


bonzero

  • Posts: 487
very simple & useful! thanks

bonzero

  • Posts: 487
has anyone tested on mobile? btw

Photics

  • *
  • Posts: 719
has anyone tested on mobile? btw

I just tested it on Android. It works.

This should be moved to core – IMMEDIATELY!

Although, there is one issue. The hover help text is missing for the green blocks. I think that's the reason for the errors in the log. (Screenshot included.)
Michael Garofalohttp://photics.com – Author of The Interactive Stencyl Textbook 8)

Jon

  • *
  • Posts: 17523
If you'd like to move this into the core (when you've got this all pinned down), you've got my OK to do this. Scene > Actors would be the right spot... I think.

captaincomic

  • *
  • Posts: 6109
Hm, where do I add the help text to get rid of the "Missing ..." warnings?

Jon, by moving to the core, do you mean to auto-include the extension like the Tile API, or to add the blocks to the normal palette?

SadiQ

  • Posts: 1778
Hm, where do I add the help text to get rid of the "Missing ..." warnings?

That's something I'd like to know as well.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Jon

  • *
  • Posts: 17523
Hm, where do I add the help text to get rid of the "Missing ..." warnings?

Jon, by moving to the core, do you mean to auto-include the extension like the Tile API, or to add the blocks to the normal palette?

Add to the normal palette.

Jon

  • *
  • Posts: 17523
Hm, where do I add the help text to get rid of the "Missing ..." warnings?

That's something I'd like to know as well.

I've now added support for this. Use the "help" attribute to specify this.

ahmadoweda

  • Posts: 307
I've heard that the layers problem would be solved in 3.1, Am I still in need to this extension after 3.1?

captaincomic

  • *
  • Posts: 6109
I've heard that the layers problem would be solved in 3.1, Am I still in need to this extension after 3.1?
I'll add it to the normal palette, then the extension won't be needed anymore.  I guess I'll get it done in time for 3.1.

ahmadoweda

  • Posts: 307
and if I used it now, after I update to 3.1 it will work fine? or I need to re-do it with the normal palette? so I need to wait for 3.1?