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

Set Parent Behavior?

A topic by Shadowblitz16 created Apr 11, 2016 Views: 488 Replies: 2
Viewing posts 1 to 3

is it possible to inherit code from a behavior?

I tried setting "class PlayerBehavior extends EntityBehavior"

but the code doesn't run

It would be cool to see some sort of help tab in superpowers that shows anwsers to categories of questions

Yes it's possible but personally I encounter few problems, sometimes it works, sometimes not.

Uncaught TypeError: Cannot read property 'prototype' of undefined


PS : Don't forget to call super methods if you use them.

class A extends Sup.behavior {
  awake() {
    Sup.log("Awake from A");
  }
}
class B extends A { awake() { super.awake(); Sup.log("Awake from B"); } start() { Sup.log("Start from B"); }
}

It seems inheritance works fine as long as the base class occurs before the derived classes. I guess during compilation, user scripts are collected and fed to the compiler in some order. The base class has to appear earlier in that order. It's easier to insure an ordering if all the scripts are under the same group.