Hello Playcanvas community!
I’øve been working on my game for some time now and want to implement highscores. I have used Kongregates API with other engines and it works great. However I can’t seem to figure out how to add the
<script src='https://cdn1.kongregate.com/javascripts/kongregate_api.js'></script>
line, which I’m supposed to do.
I’ve been looking at tutorials but they all seem to be of the old scripting system so something always goes wrong, and some things seem unable to translate.
What I’m currently using is:
var KongregateApiadder = pc.createScript('kongregateApiadder');
// initialize code called once per entity
KongregateApiadder.prototype.initialize = function() {
console.log(pc.AssetRegistry);
var asset = this.app.assets.findByTag("apii");
console.log(asset.resource);
var div = document.createElement('kongregatediv');
div.innerHTML = asset.resource ||'';
document.body.appendChild(div);
asset.on('load', function()
{
div.innerHTML = asset.resource;
});
this.app.assets.load(asset);
};
// update code called every frame
KongregateApiadder.prototype.update = function(dt) {
};
Where “apii” is a html file containing the previously mentioned line. For this code I get > asset.on is not a function
Any help with implementing the Kongregate API is much appriciated!