2017-01-17 34 views
2

我正在開發移動遊戲,但我還是新手。我想在遊戲的主屏幕中創建一個登錄/註冊/ fb表單。我在phaser的index.html中做了一個html表單,但是我有一些疑問。我怎樣才能實現HTML和Phaser的場景之間的溝通?我創建了全局變量,但我認爲這不是一個好的做法。移動登錄/註冊表

有沒有任何選項可以使用像MyGame.MainPage.startGame()這樣的html狀態?

這是該指數的js腳本,功能相關的登錄按鈕:

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

這是移相器的的MainPage一幕:

/*********************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); 
    } 
}; 

回答