Jump to content

Search the Community

Showing results for tags 'states'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





  1. this seems a rudimentary task, but i'm actually having trouble implementing a title screen into a game. i've saved this task for last thinking it simple, but i can't seem to find a way to do it cleanly. i believe the creation of "states" is involved, but i can't figure these out, and the one example on the phaser website is hopelessly confusing. everything in this project thus far is located in a single "game.js" file. i tried making a separate "title.js" and going from there, but perhaps this is the wrong approach. i simply want something that occurs before the game.js, shows a static im
  2. Hello, I have different states like "menuState", "optionState", "playState". In optionState I have more than 50 toggle buttons (possible frames: 0 and 1) So, I can include/exclude different cities by clicking those toggle buttons. Let's say I click toggle button next to "Berlin", this city is excluded from an array, and button's frame is set to 1 now. It works fine for all cities, but if I go to menuState or playState, then I go back to optionsState, those toggle buttons are created again, and their frame is 0 by default. Is is possible to save those buttons (keep them on f
  3. Hi all! Does anyone know where I might look to find some tutorials regarding best practices (basic phaser 3 game code/file structures) and perhaps some resources on STATES? If I could get some resources for using states in Phaser 3 I would really appreciate it! I keep running into an issue with "game.state.add" being undefined? Basically, if someone could point me to some very basic JS related Phaser 3 tutorials (video or article is fine) I would greatly appreciate it! P.S. A little background on me: Several years of experience using PHP/MySQL, released several text based R
  4. Hi, I don't know if this is a stupid question, but I want my game to go fullscreen when on mobile/touch screen devices only. I also need it to stay fullscreen across multiple states. Any ideas?
  5. Gammerr

    Phaser States

    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); } }; Wh
  6. I've read through just about all of this guide (https://github.com/kittykatattack/learningPixi). I think I have a grasp of how to switch stages/scenes. There's one part that doesn't make sense to me however. If I wanted to create a separate .js file for every class and every scene's code, what's the best practice for loading those files? I've seen examples where the index.html file just includes all of the scripts, but isn't that possibly a slow and/or bad experience? A previous flow I read about was loading the bare minimum (a background, logo, and loading graphic) and then loading all
  7. I have been trying to use phaser examples in my games. I noticed that the examples are not using states. The game that I am developing is using states, so I can't use the examples because I keep getting errors. Here's an example of what I am talking about: Phaser example: game.input.onDown.addOnce(updateText, this); my code game.input.onDown.addOnce(this.updateText(), this); What am I doing wrong? What can I do different?
  8. casey

    get state

    I'm trying to get the name of the current state that I am in. getCurrentState() returns a whole lot of information, including but not limited to the specific state name. How do I just return the current state (i.e. 'myCurrentState')? var myCurrentState = { preload: function () { }, create: function () { game.stage.backgroundColor = '#cce5ff'; var test = game.state.getCurrentState(); console.log(test); //logs out way too much info } };
  9. Hello! I wasn't sure what to call it but I am working on a game with my husband (terrible idea, he's a designer..) and he asked if I could create a menu screen that plays out a little scene or something. He showed me this video as an example of Mario Kart SNES (only watch the first 35 seconds of so): https://www.youtube.com/watch?v=AlAmXXNz5ac I am aware of how to use states and all but, I only just started using Phaser and I was trying to think out how I would create something similar to the scene played out in the example (Maybe something not so complex), also if this is possible h
  10. If I have multiple states (say, 30) that are somewhat resource heavy (audio, background graphic, graphics), is it better to run a single preloader at the start and preload everything I'm going to need in the game, or preload the next state ahead in each state? So if I'm in a room, and can travel to 3 other rooms from my current room, should I be preloading those 3 rooms in my current state while the player is there, etc. or preloading them all in advance?
  11. Hey there, I'm trying to get a key to always call a certain function, regardless of which state my game is in. At the moment, my code is this: var escKey = null BasicGame.Boot = function (game) { //... }; BasicGame.Boot.prototype = { init: function () { escKey = game.input.keyboard.addKey(Phaser.Keyboard.ESC); escKey.onDown.add(function(){console.log("esc")}, game); } And so on. escKey stays defined in all states, but onDown doesn't trigger. If I move the two lines within init to a state, I can use ESC in that state, but not in any state after that. Is th
  12. I Just finished the beginners "Making your first game" tutorial. I'm a student and I want to integrate phaser into my final project, but have never used it before This is my second day and I currently am confused about how to make multiple levels by implementing states. Basically I want the player to reach a certain object in the game and when they interact I want the level to change to the next level. I would like to be able to call this.state.start('level_two'); once the object has been reached. I am just confused on how to do a basic set up of states. Any advice or direction?
  13. Hi guys, I've tried everything, but still cannot get my game to have states. I hate to post my whole code but I have no idea what else to do. If anyone has a bit of time, please let me know what you think. A noob in these matters, I still don't get why I have to use 'this'. Also tried to do this in different files but nothing. I just want a basic 'play' menu, the actual game, and then the 'play again'. Am I doing something wrong in the code that prevents this to have states? I also tried the game.pause = true, but as it pauses everything and buttons won't work. 'use strict';
  14. I recently finished a very simple game, but there's still some juddering and uneven framerate even though there's really not much going on. 2-3 milliseconds per frame according to https://github.com/englercj/phaser-debug All I can think is that there's something that occasionally takes a few too many milliseconds that I need to optimise or move from one state to another. Or maybe there's a deeper problem? What are the best practices for the types of code and game logic recommended for each state? What are the best approaches to finding the offending code and the subsequent optimisation? boot:
  15. Hello, I'm new to the Phaser framework and I'm trying to have a single backgound and logo througout all the states in a phaser game. I add the background image in the very first state but when I start the next state using: this.game.state.start("State2"); the background image disappears. Do I have to load the background image in every state? Thanks
  16. Hello, I'm using Phaser for a school project. were making a 2d platformer game. I have multiple states for different levels. The transition works fine, next level is displayed properly, enemies function as the should, everything scrolls, but the keyboard stops recognizing input. right now i have: this.cursors = this.input.keyboard.createCursorKeys(); in the create function of both Level.js and Level2.js but they are not working for level 2. i have also modified the create cursor keys function in phaser.js to add a few key codes so now it reads like this: return this.addKeys
  17. Hey everybody, excuse my poor english ! I was using a single JS file for my program structured like this : index.html with <div id="timediv"></div> script.js with my Phaser code including anim function called in ajax.js. This function was declared after the update in script.js. ajax.js with function refreshdiv() which call lance() which call anim() every 60 seconds. Everything was ok like this Now I want to use states. I made : bootState, loadState and the main state called scriptState. But where do I have to place anim() de
  18. Hi I have an issue in my game.js these are snippets from the entire code where bullets and enemies overlap, but when they overlap the game crashes?: create : function(){ this.enemies = game.add.group(); this.enemies.enableBody = true; for (var i = 0; i < 1; i++) { var s = this.enemies.create(game.world.randomX, game.world.randomY, 'enemy1'); s.name = 'enemy1' + s; s.body.collideWorldBounds = true; s.body.bounce.setTo(0.1, 0.1); s.animations.add('walk', [0, 1,]); s.play('wa
  19. Hi All i was wondering if someone could help me with a phaser state query. I have been learning phaser from phaser.io and its all for a html index file however the code seems to be different then to what i need if i was to build a game with states. For example i have a player walking animation but converting it for js states seems to be very difficult, i cannot find a tutorial anywhere. Any chance someone could point me in the right direction? happy to share the code Thanks
  20. Our game is a runner, which has portals that sends you to a different time period and place when you run into them. I've made it so when you get in a portal, the code goes from one state to the other and create the world over again with different textures. But I have this issue that the player gets super speed after the portal. Like, I can run 10000px in the matter of 2 seconds speed. I have not been able to find out why so far, but with a couple of console logs I've notice both the old state and then new state updates are both running. So thought removing the run function in the new world sta
  21. Hi there! I'm new around here, and I'm quite new to JS and especially Phaser. I did a little bit of AS3 a few years back but I'm still pretty rusty, so right now I'm not really able to pull off what I have in mind. I hope you guys can help me out a bit! So, first things first, I am using a multi-state, multi-file-structure to keep it clean. I have succeeded in writing two classes which both have their own file, expanding Sprite and Group. This here is the constructor for the Class that uses Group, nothing fancy. Board = function (game) { Phaser.Group.call(this, game); }; B
  22. 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
  23. Hello All, I apologize in advance for the wall of code. Also, thanks in advance to anyone who is willing to take a crack at this. I'm having a very specific issue which I am guessing is an issue with my implementation and not the library. I am using Phaser Editor with Phaser CE as my framework. Last week I began working in prefabs into my game using extended sprites as per this example. The prefabs are separate scripts which are included in index.html. Everything has worked well except for a peculiar bug which is that when my player prefab overlaps a group which is being
  24. Hi all, I'm trying to get a handle on using states correctly. I'm creating a fishing game, which has an over-world you walk around in, and can approach different bodies of water. Once you get near one you can press space to fish. I then start a new state, which will be a mini-game where you try to catch the fish. Then I want to return to the over-world with a successful (or not) catch. Right now, I can start the mini-game phase (miniGame.js), passing in the fish to catch, but when I return to the overworld (Game.js), I can't display the fish or add it to the inventory, because I'm tr
  25. Hi, for my game I use a simple state order like: Main Menu -> Map screen -> Level 1 -> Map screen -> Level 2 -> and so on That works well Just separate everything in logical chunks. But now I had the Idea of implementing some kind of minigames interrupting the level. And thats the point. If I make a state change, the state is resetted if the minigame itself is a state too. Other version is, that the minigame is just a game packed in a group on top of the current state. but this approach make some trouble too cause of physics side effects. So what I desir
  • Create New...