Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
78
rated 0 times [  79] [ 1]  / answers: 1 / hits: 5296  / 4 Years ago, mon, january 13, 2020, 12:00:00

My code works with all the other modules but JBehaviour is giving me this problem and idk what im doing wrong because it seems like I did everything right




Full Error:
Uncaught TypeError: Class extends value # is not a constructor or null
at Object. (C:UserseternDocumentsGameEnginesrcengineclassesJBehaviour.js:3)
at Object. (C:UserseternDocumentsGameEnginesrcengineclassesJBehaviour.js:11)




test_game.js



const {Vector2, GameObject, Rigidbody2d, JBehaviour, Input} = require('./Core')


Core.js



//Structs
const Vector2 = require('./structs/Vector2')

//Classes
const GameObject = require('./classes/GameObject')
const Rigidbody2d = require('./classes/Rigidbody2d')
const JBehaviour = require('./classes/JBehaviour')
const Input = require('./classes/Input')


module.exports = {Vector2, GameObject, Rigidbody2d, JBehaviour, Input}


JBehaviour.js



    const Behaviour = require('./Behaviour')

class JBehaviour extends Behaviour{
constructor(){
super('JBehaviour')
}
}


module.exports = JBehaviour


Behaviour.js



const Component = require('./Component')

class Behaviour extends Component{
constructor(name){
super(name)
this.enabled = true
}
}


Component.js



const OBJ = require('./Object')
class Component extends OBJ {
constructor(name){
super(name)
this.gameObject = null
this.tag = null
this.transform = null
}

AssignGameObject(gameObject){
this.gameObject = gameObject
this.tag = gameObject.tag
this.transform = gameObject.transform
}

CompareTag(tag){

return (this.tag === tag)
}
}

module.exports = Component


Object.js



class OBJ{
constructor(name){
this.name = name
}

static Destroy(object){
delete object.name
}

static Instantiate(original){

return new OBJ(original.name)
}

ToString(){

return toString(this.name)
}
}

module.exports = OBJ

More From » javascript

 Answers
0

You didn't export Behaviour, so the value returned by require('./Behaviour') is an empty object. Empty objects can't be extended from.



Export Behaviour like you do with JBehaviour:



module.exports = Behaviour

[#5062] Friday, January 10, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nestorjarettg

Total Points: 451
Total Questions: 108
Total Answers: 108

Location: Rwanda
Member since Thu, Feb 10, 2022
2 Years ago
nestorjarettg questions
;