Parenting doesn't affect position

16 views
Skip to first unread message

Joshua Jebadurai

unread,
May 11, 2020, 11:27:14 PM5/11/20
to excaliburjs
Is there a purpose for Actor.parent, I set that a child and nothing happened to the child, it didn't move along with the parent.

DaVince

unread,
May 12, 2020, 7:05:44 AM5/12/20
to excaliburjs
What does your code look like?

I always thought Actor.parent only worked the other way around: you can use parentActor.add(childActor) to add a child, and childActor.parent can then be used to refer back to the parent. But looking at the source code there's no reason why it shouldn't work the way you're using it. It might be a bug?

Note that there are plans to replace the parent-child actor system with something else entirely, though.

Joshua Jebadurai

unread,
May 12, 2020, 9:47:44 AM5/12/20
to excaliburjs
I'm using childActor.parent = parentActor, then move the position the parentActor, which means it suppose to along with it right?
Anyway, I found a workaround for the game.

Note that there are plans to replace the parent-child actor system with something else entirely, though.
containers? I moved from Phaser 3 because of that, Phaser 2 was simple enough to use when it comes to hierarchical game objects.

DaVince

unread,
May 12, 2020, 10:01:20 AM5/12/20
to excaliburjs
On Tuesday, May 12, 2020 at 3:47:44 PM UTC+2, Joshua Jebadurai wrote:
I'm using childActor.parent = parentActor, then move the position the parentActor, which means it suppose to along with it right?
Anyway, I found a workaround for the game.

I would think so, but it sounds like it's bugged.

If instead you do:
parentActor.add(childActor)
It does work. (If it doesn't, that's also a bug.)

Also, I'm curious about your workaround :)
 

Note that there are plans to replace the parent-child actor system with something else entirely, though.
containers? I moved from Phaser 3 because of that, Phaser 2 was simple enough to use when it comes to hierarchical game objects.

It seems like there's going to be a GraphicsGroup class that you pass any kind of graphical element to. I'm not the one developing this, but I'm hoping for it to be generalized enough that you can still add(), render() and set a parent position on it, just the way we can now.

A branch of Excalibur that implements the new graphics API is in development at https://github.com/excaliburjs/Excalibur/tree/feature/drawing-graphics-redo/src/engine/Graphics. I'm sure they'd appreciate some feedback. :)

Erik Onarheim

unread,
May 12, 2020, 10:14:01 AM5/12/20
to DaVince, excaliburjs
Child actors are pretty buggy unfortunately, we are building out a new graphics api to eventually serve their purpose of hierarchical drawing. Definitely check out the gist and let us know what you think https://gist.github.com/eonarheim/3b243b78ce0711fc6c9ae63261521ad5  

parentActor.add(childActor) Should work at the moment (if not it's definitely a bug as Vince says)

--
You received this message because you are subscribed to the Google Groups "excaliburjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to excaliburjs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/excaliburjs/3176277c-7c75-467a-9a57-80e61eaee30d%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages