Phaser登录/注册表单

时间:2017-01-17 09:34:11

标签: javascript facebook game-engine phaser-framework

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

1 个答案:

答案 0 :(得分:0)

您可以尝试使用此Phaser插件 https://github.com/orange-games/phaser-input

相关问题