我正在用phaser开发一个游戏,但我还是个新手。我想在游戏的主屏幕上创建一个登录/注册/fb表单。我在phaser的index.html中做了一个html表单,但我有一些疑问。如何实现html和phaser场景之间的通信?我创建了全局变量,但我认为这不是一个好的做法。
是否有任何选项可以使用html中的状态,如MyGame.MainPage.startGame()?
这是索引的js脚本,函数与login按钮相关联:
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);
}
};发布于 2017-02-06 05:34:06
你可以试试这个相位器插件https://github.com/orange-games/phaser-input
https://stackoverflow.com/questions/41693524
复制相似问题