Search the Community
Showing results for tags 'structure'.
-
So states are the right way of creating screens in the game, right? So let's say I have a menu state and I have a game state, so my game state looks like that: var gameState = { init: function(levelData) { this.levelData = levelData++; }, create: function() { var jumpLebel = game.add.text(140, 200, 'press ESC to jump to MENU', { font: '25px Arial', fill: '#ffffff'}); var escKey = game.input.keyboard.addKey(Phaser.Keyboard.ESC); escKey.onDown.addOnce(this.goToMenu, this); }, start: function() { this.game.state.start('menu', true, false, levelData); } }; Where is the right place to put my init variables of the game on the init function? after the init function? on the create function? should be in another state file? maybe the bootState? Can you help me with that structure please? Also I'm watching the tutorials of Pablo at udemy.com and he's not explaining why sometimes he's using 'this' and sometimes not, for example (section #4, Lecture #39 - Basic Structure): create: function() { this.ground = this.add.sprite(0, 500, 'ground'); var platform = this.add.sprite(0, 300, 'platform'); this.player = this.add.sprite(100, 200, 'player', 3); }
-
Hi everyone. I have experience with phaser making small arcade like games. But I now want to make a larger platformer with worlds. I cant figure out how to organise my code for each world and how to switch between worlds. Can anyone provide me with some guidance on how I can do this?
-
Hello! I have the following task to do in the next following 3 weeks: create a real-time multiplayer strategy game. I have no experiance in making multiplayer games, no experience in phaser io, node js or using web sockets. But I am a fast learner and I already learned a few things about those libralies. I am thinking of using Angular and phaser for the client side. Nodejs and socket io for the server side. The thigs I need to be done: -multiple game rooms -states for the game(menu, playing, game) -user authentication -interacting on a MySQL table for users (connecting two servers) -building logic for the game -real time syncronisation between every player, every unit(when it shoots, move) Ok so the first 5 issues won't be such a dificulty for me and if it was a single player game I probably wouldnt ask this question. I am really asking for help for building the base thing and some "proof of concept". I need to connect the two players in one room, need to when a single unit is moving and shooting to some building, and the building(tower) shoots back this to be sincronized and to work for lets say a 100 units. Where do I start? What metod do I use? 1. Shoud I have game state on the server and this logic to be in the server so everything is syncronized? So when two player start playing the game, the server also (plays the game) in some kinda loop until the game ends. And sends to the users JSON lets say 30times/second. And the user interact to the game logic with controllers, which sends the info to the server and server updates it's state, mean time the client still gets every second a lot of json objects, and rerenders on every change. 2. Using Observer pattern with syncronizable interface, for keeping track of enemy possitions on your client. The server is only used or transfering data and authorising, nothing else. Have sepparate game states on each client, which you syncronise with other clients? So which method would you advice me to start with for my prove of concept(I accept other sugsestions)? How should I build my archictecture? The prove of concept is the basic thing that I should start with but is the most hard one. I am way over my head. I would really use some help. Thanks!
- 5 replies
-
- multiplayer
- strategy
-
(and 5 more)
Tagged with:
-
Hi there! So basically, to cut to the chase. I have an issue that isn't really causing problems as of yet, but I'm worried that it might in the future and I'd rather not get into a habit now that might come back to bite me later. My question is simply as stated above, can there be such a thing as too many JavaScript files in a Phaser game project? I understand the answer to this is yes, but how many would you advise as the cut off point? To help with this I'll provide a little context. I'm currently making a project at the moment as a sort of test bed for a new game idea, but currently my planning has led me to create an extremely split up approach to the game, whereby each object is being created as an extension of either Phaser.Sprite, Phaser.Group etc. Using these, I'm creating prefabs and defining their variables and methods within them and then controlling these as a wider whole throughout. Now, to keep the project structure relatively clean and manageable I'm splitting these object's into separate .js files in a "class" style approach, but this has led so far to me having at least 14 .js files for the objects alone and at least 7 .js files for the game's states. The reasoning for my worry is that I'm sure that having 21 or possibly more .js files is going to cause an extremely long page load time or bottleneck for the end user. Although, I'm not moving between pages so caching and reloading scripts might not be a large issue, but I'm still unsure if this is maybe a bad practice and approach to creating a Phaser game and to a greater extent, HTML5 games in general. But, saying that, would it fix any possible bottlenecks if I were to create a "published" build whereby I place all of my game's logic into one large, minified .js file? Is there any advice on this subject? I know it's fairly open and possibly more opinion based rather than definitively answerable, but I'm extremely confused and any help offered would be appreciated.
- 5 replies
-
- structure
- maintenence
-
(and 3 more)
Tagged with:
-
Hi All, Anybody in here already create game using phaserjs and embeed to moodle ? i have some problem to do that, if anyone have success, please give me advise. Thank You, P
-
Hi guys, I am a new member to this community and entirely new to HTML5 game development. I came across Pandajs on my search for a viable 2D game engine with which I can pick up and excel my skills in HTML5 game development. Thanks to enpu for making this game engine! The below links and examples from github helped me to overcome issues during my initial stages of development. Like adding Sprite, Animations and Containers and also creating Modules and Classes. Even though I was able to achieve these, there are these couple of concepts which I am still unclear of and need help from someone to completely understand. I searched through the forums and also blogs to get some idea, but got lost. Finally I decided to post it here. What I would like to understand is 1. The structure of the game engine. The classification of game.module(), .body(function(){}), game.createScene() and others in it. 2. The relation of game.scene, this.body, shape, world and so on. Is it necessary to have all of these? If so, why? 3. If there is difference between game engine version 1 & 2 with regards to the structure? I would be very happy and thankful if someone can help me clear these doubts. Let me know as to where I can find/read the basics of HTML5 game devleopment, especially on Pandajs. Sorry to ask these questions if it has already been answered in this forum. Links I went through http://www.pandajs.net/cheatsheet/ http://vermeire.home.xs4all.nl/panda/index.html http://www.emanueleferonato.com/2014/03/05/look-at-panda-js-html5-game-engine-capabilities-with-a-working-game-prototype/ http://www.ninjadoodle.com/blog/tag/pandajs/
- 4 replies
-
- beginnersfundamentals
- basics
-
(and 6 more)
Tagged with:
-
Hello! I've been trying out Phaser for mini games that make a part of a larger whole. So far it's working out great and haven't bumped into any problems yet with the games. Problem is that they will go into a semi large project and in order to keep a good structure and compile times down I'd like to know how to be able to work on the games separately from the main app. The games themselves will also have states of their own. Basically what I'm looking for is a solution like loading a sub.swf into a main.swf at some point in time and then later unload it again. I've searched but haven't really found anything that answers my question. In theory I could just link from one html page to another, but I don't think that really the way it should be. Any clues for a direction to take would be greatly appreciated! //summer
-
Recently I have been following an ongoing discussion regarding mobile performance and efficiency. One of the recommendations that caught my eye was to avoid classes and prototyping altogether because they can slow down the performance significantly. So far I have structured my code by creating separate class objects in different files by using prototypes. class = function () {}class.prototype.myMethod1 = function () { console.log('myMethod');}class.prototype.myMethod2 = function () { console.log('myMethod2');}In this regard, I am wondering what is the recommended and most efficient way to structure your code? Perhaps the more experienced users can share something from their bag of tricks. Thanks
-
When using Flixel I would have a gamestate, a player, enemy, perhaps coins etc as separate classes. Maybe a registry that stored assets etc. I had been tooling around with ImpactJS and that framework uses a similar structure. How do I implement a structure like this with a Phaser game? I only want the the index.html to set the css etc and load the game.