Looking at the sample project called Cube Jump (PlayCanvas | HTML5 Game Engine) while developing the Playable Ads for various platforms I came to the point where I need help / suggestions.
In the beginning I was making a playable for UnityAds which utilizes mraid.js various functions and made a script which loads before the engine:
if (mraid && mraid.getState() === 'loading') {
mraid.addEventListener('ready', onSdkReady);
} else {
onSdkReady();
}
function onSdkReady() {
mraid.addEventListener('viewableChange', viewableChangeHandler);
// Wait for the ad to become viewable for the first time
if (mraid.isViewable()) {
if (pc.Application.getApplication()) {
pc.app.fire('playable:viewable');
}
}
}
function pcGameReady() {
if (pc && pc.Application.getApplication() && mraid && mraid.isViewable()) {
pc.app.fire('playable:viewable');
pc.app.fire('music:play');
}
}
In the start.js script we use:
Start.prototype.postInitialize = function() {
pcGameReady();
};
The challenge for the Snapchat Playable Ads is to utilize these mraid.getState() and mraid.isViewable().
BTW the Rest-Api-Tool fails on having before-engine scripts and “extern_files.enabled”: true.
The question is should we try to make playable utilize the features of the mraid or we should keep it simple without too much over-engineering ?
Thanks in advance