Search the Community
Showing results for tags 'form'.
-
Hey guys, I added a form to my game, wanting to let the user choose a seed. <form onsubmit="getSeed(event)"> <span>Seed:</span> <input id="seed" type="number" name="seed" value="111" /></form>My structure of my code is like so: module ModuleName { export class World extends Phaser.State { ... create() { ... } getSeed(event) { event.preventDefault(); console.log("submitted"); var seed = document.getElementById('seed')["value"]; ... }}How can I get my function to run, how do I target it? I obviously get an error (ReferenceError: getSeed is not defined) since it can't find my getSeed function. Is it even targetable from outside? Putting "public" infront of the function didn't help, I also tried game.getSeed(), this.game.getSeed(), game.World.getSeed() and a few others to no avail. :/ Also, a bit off topic: Would you take another route than adding an html form?
-
Hi, I am developing a game in phaser but I am newbie yet. I want to create a login/signup/fb form in the main screen of the game. I did a html form in the index.html of phaser, but I have some doubts. How could I achieve the communication between the html and the scenes of phaser? I created global variables, but I think that is not a good practice. Are there any options to use a state from html like MyGame.MainPage.startGame()? This is the js script of the index, the function is associated to login button: function login(){ user = check_user_in_db(); if(user){ //If the login is correct variable.startGame(); } } This is the MainPage scene of Phaser: /*********************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); } };
-
hi guys, I'm newbie for phaser framework, currently I have a problem that: I want to make a setting page in the game, when I click the setting button, it will popup a setup page (have some option to choose, just like a html form). after setting done, close the popup setting page and continue the game. But I have no idea how to implement this feature, is anyone have some idea or suggestion, (I don't know how to use original html dom in phaser) many thanks.