How do I use Z index to get an parent actor draw on a children actor?

42 views
Skip to first unread message

Maxime FB

unread,
Sep 27, 2017, 2:57:36 PM9/27/17
to excaliburjs


I am doing a menu and I want to create a selector of this menu and for doing that, I create a menu that contains many class extends of actor to create a list of actors. I want to create a selector for this menu where a pointer select the current actor, but my pointer is in the menu and each actor are draw over the menu but i would like to put the selector draw on each element. So how do I define a actor to be draw over an other actor. I have thought it would be the Z index but I only get this type of error when trying to change it :
[Fatal] :  TypeError: Cannot read property 'cleanupDrawTree' of null   excalibur.js:4909 
    at b.setZIndex (excalibur.js:14002)
    at b.set [as z] (excalibur.js:13983)

I dont post code but if it need to be clearer, I will post it.

Erik Onarheim

unread,
Sep 27, 2017, 8:01:56 PM9/27/17
to excaliburjs

Hi Maxime,

I'm able to reproduce the issue you are seeing with child actor z-index (codepen https://codepen.io/anon/pen/YrVwOe?editors=0010). I've opened a bug on github https://github.com/excaliburjs/Excalibur/issues/888

As a work around do not use child actors to create a menu. Create a plain TypeScript class that contains all your buttons added to the root scene.

See this working example:

Let me know if I'm on the right track for what you want.

The cursor can also be styled with CSS which might be better depending on what you are doing https://developer.mozilla.org/en-US/docs/Web/CSS/cursor

Cheers,
Erik
Reply all
Reply to author
Forward
0 new messages