Hi,
I am trying to create a script called modules.js, but I can't use runtime anywhere, because it shows as undefined. Here is my code, attempting to do what Ashley suggests:
// Import any other script files here, e.g.:
// import * as myModule from "./mymodule.js";
function getRuntime(runtime) {
return runtime;
}
import animate_playbackState from "./animate.js";
import animate_directionalState from "./animate.js";
// Global variables
var playerInstance = getRuntime(runtime).objects.iPlayer.getFirstInstance();
runOnStartup(async runtime =>
{
// Code to run on the loading screen.
// Note layouts, objects etc. are not yet available.
runtime.addEventListener("beforeprojectstart", () => OnBeforeProjectStart(runtime));
});
async function OnBeforeProjectStart(runtime)
{
// Code to run just before 'On start of layout' on
// the first layout. Loading has finished and initial
// instances are created and available to use here.
runtime.addEventListener("tick", () => Tick(runtime));
}
function Tick(runtime) {
// Animate.js
if (animate_playbackState) {
switch (animate_directionalState) {
case 'up':
playerInstance.angle = 270;
case 'down':
playerInstance.angle = 90;
case 'left':
playerInstance.angle = 180;
case 'right':
playerInstance.angle = 0;
}
}
}