Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
0
Members

Extending from Actor

A topic by carterza created Jan 22, 2016 Views: 540 Replies: 2
Viewing posts 1 to 3
(1 edit)

If I want to subclass Sup.Actor, how would I go about placing an instance of my subclass in a scene? Would I need to manually edit the scene file? Is this possible via the editor?

I don't have a strong case for doing so at this point - I'm pretty sure I can accomplish what I need to with a behavior. I was just curious. What got me thinking about doing this was the fact that the behavior class I was writing would not be reusable. I realize I'd be writing code either in one class or another either way - but the docu on the behavior page got me interested since it describes behaviors as being reusable (I understand they're the equivalent of a component in an ECS).

Thanks!

-Zach

Moderator(+2)

Hey Zach,

Subclassing the Sup.Actor class isn't really supported, you should be able to accomplish everything you need with Behaviors, I think. You can access properties and methods on a behavior from the outside like so:

Sup.getActor("Some Actor").getBehavior(SomeBehavior).someProperty

And if you need to build a complex reusable actor made of multiple components or with children actors attached to it, you can build your reusable actor hierarchy in a separate scene and then import it many times in your main scene with the "New Prefab" button.

Hope that helps.

Yeah that's what I figured - curiosity just got the best of me. Thanks for the explanation Elisee!