我正在用相位器开发游戏,但我还是新手。我想在游戏的主屏幕中创建一个登录/注册/ fb表单。我在phaser的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();
}
}
这是Phaser的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);
}
};