2017-01-17 24 views
2

私はフェイザーでゲームを開発していますが、まだ初心者です。私は、ゲームのメイン画面にログイン/サインアップ/ fbフォームを作成したいと思います。フェイザーのindex.htmlにhtmlフォームを作成しましたが、疑問があります。どのようにして、htmlとフェイザーのシーンの間のコミュニケーションを達成できますか?グローバル変数を作成しましたが、それは良い方法ではないと思います。フェイザーログイン/登録フォーム

MyGame.MainPage.startGame()のようにhtmlの状態を使用するオプションはありますか?

これは、インデックスのjsのスクリプトでは、機能がボタンをログインする関連している:

function login(){ 
    user = check_user_in_db(); 
    if(user){ //If the login is correct 
     variable.startGame(); 
    }     
} 

これは、フェイザーのメインページのシーンです:

/*********************NAMESPACE********************/ 
var MyGame = MyGame || {}; 
/**************************************************/ 

/******************INIT APP SCENE******************/ 
MyGame.MainPage = function(game) 
{ 
    variable = this; 
}; 

MyGame.MainPage.prototype = 
{ 
    init: function() 
    { 

    }, // init 

    preload: function() 
    { 
     //load Sprites 
    }, //preload 

    create: function() 
    { 
     //create Buttons 
    }, // create 

    shutdown: function() 
    { 

    }, // shutdown 

    startGame: function(){ 
     this.state.start("Menu", true, false); 
    } 
}; 

答えて