JSFiddle - React, Tailwind, and code Playground
JavaScript
MyGame = {};
// game object
MyGame.start = function () {
// initialise image
this.imageShapes = {};
// add gamedata and populate by loading json
this.gamedata = [];
this.test123 = 'This is a test value 123';
this.loadJSON();
}
MyGame.start.prototype = {
// load a JSON file
loadJSON: function() {
var callback = function() {
this.onJSONSuccess();
};
setTimeout(callback.bind(this), 100);
},
onJSONSuccess: function() {
console.log(this);
this.imageShapes.src = 'img/mybackground.png';
console.log(this.imageShapes);
}
};
new MyGame.start();