主に C++ と Javascript を使用する 3D 学習ベースのゲームに取り組んでいます。プレイヤーがノートブックに情報を送信したときの通知システムを設計しようとしています。
システムをセットアップしましたが、スーパーバイザーは改善できると考えています。ここで皆さんの助けが必要です!
それが行った非常に基本的な方法:
プレイヤーは、ノートブックに送信される情報をトリガーする何かを行います。これが起こったのと同じ方法で、通知をオンにしました。通知は、画像の 2 つの div を点滅させる (点滅効果を作る) ことによって、プレーヤーの画面に表示されます。これらの div のいずれかがクリックされると、プレーヤーにノートブックが表示されます。プレーヤーがノートブックを表示または終了すると、通知はオフになります。
今ここに私が使用していたコードがあります:
メインの GameState で
int GameModeState::notify(int query)
{
static int notified;
if(query == 1)
{
notified = 1;
return notified;
}
if(query == 2)
{
notified = 0;
return notified;
}
else
{
return notified;
}
}
GameState の update 関数で
// checks if the unviewed information notification needs to be on or off
if(notify(0) == 1) // supposed to be on
{
mScreen->executeJavascript("notebookNotification(1);"); // turns it on
} else {
int nothing = notify(2); // clears out notify to 0
mScreen->executeJavascript("notebookNotification(0);"); // turns it off
}
私のJSで
var intervalID; // Needed to turn off setInterval()
//Function takes in 0 to turn off notification, anything else turns it on
function notebookNotification(setting)
{
if(setting == 0)
{
if(intervalID) {
// clears the blinking darkContainer
window.clearInterval(intervalID);
intervalID = null;
}
// hides both of the images
$("#lightNotificationContainer").hide();
$("#darkNotificationContainer").hide();
}
else
{
$("#lightNotificationContainer").show();
if(!intervalID) {
// "animates" the blinking of the notification; the darkContainer toggles on and off every second, and covers the lightContainer
intervalID = window.setInterval('$("#darkNotificationContainer").toggle()', 1000);
}
}
}
を使用して通知をオフにしますGameModeState::notify(2)
では、これよりも優れたシステムは何でしょうか?