I am having trouble accessing the necessary object properties in a method. Here I have a simplified version of what I am trying to do. I have a Game class that is used to make a new game object. Once that object has been made I am trying to run the draw method. The draw method will use information from state.house.color, but I cannot seem to figure out how to access it since using "this" in draw will not refer to the game object. I have used .bind(this) in the past, but that doesn't seem to be helping here as I would need to bind an object not a function. Thanks for any insight!
class Game {
state = {
house: {
color: "blue"
}
}
assets = {
house: {
draw(){
//some logic here such as console.log(this.state.house.color)
}
}
}
};
let testGame = new Game();
testGame.assets.house.draw();