I'm facing an issue with accessing the necessary object properties within a method. In my scenario, I have a Game class that generates a new game object. Once the object is created, I attempt to execute the draw method. This draw method requires information from state.house.color, but I'm struggling to find the correct way to access it because using "this" inside draw does not reference the game object. I've used .bind(this) previously, but it doesn't seem to work in this case as I need to bind an object rather than a function. Any advice would be greatly appreciated!
class Game {
state = {
house: {
color: "blue"
}
}
assets = {
house: {
draw(){
//some logic here like console.log(this.state.house.color)
}
}
}
};
let testGame = new Game();
testGame.assets.house.draw();