Copy link to clipboard
Copied
can i make a game with a database for highscores? working on one tablet without a LMS?
Copy link to clipboard
Copied
Do you have a webserver that you can you a database on?
Do you have a PHP programmer that can read/write information from Captivate and the database?
What do you mean "working on one tablet"?
Copy link to clipboard
Copied
The tablet/laptop is going to use in a area without any internet.
no we have no php programmer
the tablet is going to use by more then one person to play the game
Copy link to clipboard
Copied
This code should get you started.
create a user variable isHighScore = 0;
to trigger the function, call javascript: setScore("youVariableScore"); which will set the isHighScore accordingly.
In an advanced action show or hide your high score message absed on isHighScore = 1 for true.
Put the following code in the head section of your html or js file .
function setScore(sentScore)
{
var gs = Number(localStorage.getItem("highScore"));
var ss = Number(sentScore);
if (ss > gs)
{
localStorage.setItem("highScore", sentScore);
window.isHighScore = 1;
}
else
{
window.isHighScore = 0;
}
}
function setStorage()
{
if (localStorage.getItem("highScore") === null)
{
localStorage.setItem("highScore", 0);
}
}
var interfaceObj;
var eventEmitterObj;
window.addEventListener("moduleReadyEvent", function(evt)
{
interfaceObj = evt.Data;
eventEmitterObj = interfaceObj.getEventEmitter();
initializeEventListeners();
});
function initializeEventListeners()
{
if(interfaceObj)
{
if(eventEmitterObj)
{
eventEmitterObj.addEventListener("CPAPI_SLIDEENTER",function(e){
setStorage();
});
}
}
}