Search the Community

Showing results for tags 'phaser'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • 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





Found 3,316 results

  1. I don't know what to do anymore, i am using the Ninja physics system, have loaded a tilemap, am moving the player with moveLeft upon keydown, but how can i stop the movement? I tried everything, every possible method that i could think of, debugging it, but nothing stopped the darn player from happily gliding around. I assume that i don't have acces to the right body, but even after extensive debugging i can't figure out what to do! Any help would be apreciated as i am on a tight timeframe here (LD and such ) create() { //; // Activate the Ninja physics system; // disable gravity = 0; ='testlevel'); // Load tilemap'Test', 'testtiles'); // add the tile images this.layer ='Tile Layer 1'); // create layer from tilemap this.layer.resizeWorld(); // resize world to fit tilemap // create the bodies for the tiles this.ninjatiles =, this.layer, this.slopeMap); // player this.sirwalter =, 100, 'sirwalter'); // add body to player, this.sirwalter.width / 2); this.sirwalter.body.friction = 0.5;; this.cursors =; } update() { for (var i = 0; i < this.ninjatiles.length; i++) {[i].tile); } if (this.cursors.left.isDown) { this.sirwalter.body.moveLeft(20); } else if (this.cursors.right.isDown) { this.sirwalter.body.moveRight(20); } else { this.sirwalter.body.shape.velocity.x = 0; this.sirwalter.body.velocity.x = 0; } if (this.cursors.up.isDown) { this.sirwalter.body.moveUp(20); } else if (this.cursors.down.isDown) { this.sirwalter.body.moveDown(20); } }
  2. Hello everyone I have just started playing with phaser, and I am using sublime for it, so what are your favorite sublime packages? and what other IDE you suggest? Thanks
  3. eitank

    responsive screen using phaser

    I want my app will fit seamlessly mobile devices and computers. So that the user will feel naturally while using my software similar to a native mobile application. I don't need only a phone fix but also, on re-size the browser window I want to be able to respond and to change the screen. I'd like to know what is the best way to make a "responsive screen" using phaser?
  4. GameState.prototype.create = function() {this.pipe =;, Phaser.Physics.ARCADE); this.pipe.createMultiple(1, 'pipe'); for (var i = 0; i < 1; i++) { var block1 =, y, 'pipe') var block2 =, y, 'pipe') this.pipe.add(block1); this.pipe.add(block2); }}GameState.prototype.update = function() { game.physics.arcade.collide(this.player, this.pipe, collisionHandler, null, this);}function collisionHandler (obj1, obj2) { game.stage.backgroundColor = '#992d2d';} The above code works properly to change the background color when the player touches a block. Yay! However, I'm trying to get the update (in this case, background color change) to occur only when the player touches block1. I've tried: GameState.prototype.update = function() { game.physics.arcade.collide(this.player, this.block1, collisionHandler, null, this);}as well as GameState.prototype.update = function() { game.physics.arcade.collide(this.player, this.pipe.block1, collisionHandler, null, this);}The game runs, but no update occurs. Any ideas?
  5. I'm very pleased to announce the debut of SpaceShip Highway on the Nuggeta play store! Click the link below to play!!game/spaceshiphighway_3ce6c33d-6a0f-4b07-b256-571db26577a2 Its a simple game where you find yourself on the wrong side of a highway IN SPACE and you have to dodge your way in increasing traffic to beat the highscores. I have integrated Nuggeta's cool APIs for global highscores and achievements boards. They are a really cool bunch and be sure to check them out here -!home for their dev portal and!store for their games portal.
  6. Why do p2 sprites in a group collide with each other when collideWorldBounds=true but when I set it to false they stop colliding?
  7. Kristoffer Darj

    Rotating a sprite towards the pointer

    Hello. I'm trying to follow but my missiles end up pointing in the wrong direction all the time. So I simplified and removed basically everything but the rotation of the bullet. But even with a centered stationary bullet it ends up facing in another direction than where the pointer is. Missile.prototype.update = function() { var targetAngle = this.x, this.y,, ); this.rotation = targetAngle;}; I'm using 2.0.3 Any thoughts on what might be wrong here?
  8. Luiz Bills

    another phaser workflow (work in progress) FeaturesWhen a javascript file is created inside src/sprite folder it's filled with a template for Phaser Sprites source. The same occurs on src/state folder, but is used a template for Phaser States (see _grunt/handlebars/templates). feel free to contribute
  9. Seanw265

    Phaser Scale Tilemap Collisions

    Hello all, I'm new to HTML5 and JS game programming. I come from an Obj-c/cocos2d background. I've been struggling to get the Arcade physics to recognize the scaling of a Tilemap layer. The layer is created as follows: ='level');'tileset','tiles');, 50);this.layer ='Tile Layer 1');this.layer.scale.x = 2;this.layer.scale.y = 2;this.layer.debug = true;this.layer.fixedToCamera = false;The layer displays perfectly fine(along with the debug drawing), but the collisions do not scale at all. I have tried altering the collisionWidth and collisionHeight of the TilemapLayer and it doesn't seem to have the desired effect. I am checking for collisions in an update method by this function: game.physics.arcade.collide(sprite,layer);This was posted in regard to Phaser 1.1: I should point out that I am running Phaser 2.0.4 Any help is greatly appreciated!
  10. Hello, Using a simple box image, I'm trying to create a horizontal bar that falls down. I'd like to have random holes in the bar that the player has to move into to avoid being crushed. I'm using as a guide to creating the bar itself, but LessMilk is creating a vertical bar which moves right -> left instead of a horizontal bar moving from up -> down.
  11. markjsb

    Physics problem

    Hi I've got a slight problem with the physics in the game and it only happens on one platform, but always on that platform. If the player dies there and they click the reset game button, the game registers a 'dead' to the console log immediately. It works everywhere else... So my question is, can I reset the physics (ARCADE PHYSICS by the way!) ? Appreciate it if anyone has had problems with this sort of thing or even just how to maybe do it another way! Thanks for the great framework!
  12. mtburdon

    Gravity issue upgrading to 2.0.3

    Hi everyone, I'm going through a game I've been developing and updating it from v1.1.3 to v2.0.3, however I seem to have come across a small issue. After updating, the gravity on my player seems to act a lot differently than before. When updating I've enabled Arcade physics and enabled it on my player, when my player drops into the game now (with player.body.gravity.y set to 17 as before) it does so very slowly rather than dropping in at a normal speed. Also, when jumping, the player flies off into the sky rather than a short quick jump. Am I missing something or should I be using a different physics engine here? Thanks, Martin
  13. in function create(): create 15 cubes on the top of gameworld: stars =;for (var i = 0; i < 15; i++) { var star = stars.create(375, -50, 'star'); game.physics.arcade.enable(star); star.enableBody = true; star.body.collideWorldBounds = true; star.body.immovable = true; }timer:, updateCounter, this);in function updateCounter, make the cubes fall down one by one: if(i<15){live = stars.getAt(i);live.body.immovable = false;live.body.gravity.y = GRAVITY;//live.body.velocity.y = 90;i++;}
  14. I'm using VS Express 2013 for the Web and following this tutorial: My code: Game.ts ///<reference path="phaser.d.ts"/>module Crazytopia { export class Game extends Phaser.Game { constructor() { super(1023, 630, Phaser.AUTO, 'content', null); this.state.add('Boot', Boot, false); this.state.add('Preloader', Preloader, false); this.state.add('Menu', Menu, false); this.state.add('Room_1', Room_1, false); this.state.start('Boot'); } }} Boot.ts module Crazytopia { export class Boot extends Phaser.State { preload() { this.load.image('preloadBar','img/loader.png'); } create() { this.input.maxPointers = 1; this.stage.disableVisibilityChange = true; if ( { // If you have any desktop specific settings, they can go in here [b][color=#ff0000]this.stage.scale.pageAlignHorizontally = true;[/color][/b] }'Preloader', true, false); } }} Menu.ts module Crazytopia { export class Menu extends Phaser.State { username: Phaser.Text; menuTitle: Phaser.Text; create() { //this.stage.setBackgroundColor(0x2d2d2d); this.menuTitle = this.add.text(,, 'Enter your name:', { font: "30px Arial", fill: "#ffffff", align: "center" }); this.menuTitle.anchor.setTo(0.5, 0.5); this.username = this.add.text(, + 70, '', { font: "30px Arial", fill: "#ffffff", align: "center" }); this.username.anchor.setTo(0.5, 0.5); this.input.keyboard.addCallbacks(this, this.keyboardHandler); if (this.input.keyboard.addKey(Phaser.Keyboard.P).justPressed()) { this.startGame; } } keyboardHandler( evt ) { // Skip it unless it's a-z. if (evt.which < "A".charCodeAt(0) || evt.which > "Z".charCodeAt(0)) { console.log("Not a letter: ", evt.which); return; } var letter = String.fromCharCode(evt.which); if (!evt.shiftKey) letter = letter.toLowerCase(); this.username.setText(this.username.text + letter); } startGame() {'Room_1', true, false); } }} Note: there is also Preloader.ts, Room_1.ts and app.ts but I do not think they are relevant to the problem (please correct me if I'm wrong). The errors I get: Error 1 The property 'setTo' does not exist on value of type 'PIXI.Point' (Menu.ts ln 17)this.menuTitle.anchor.setTo(0.5, 0.5);Error 2 The property 'setTo' does not exist on value of type 'PIXI.Point' (Menu.ts ln 25)this.username.anchor.setTo(0.5, 0.5);Error 3 The property 'pageAlignHorizontally' does not exist on value of type 'PIXI.Point' (Boot.ts ln 14)this.stage.scale.pageAlignHorizontally = true;I'm new to Typescript and Phaser so I have no idea what I'm doing wrong. Thanks for reading!
  15. Hi guys, So I'm trying to expand the game I'm making to be a multiplayer game using Node.js and The connection between server-side and client-side is working, however I don't know how to update the positions of the players. This is how it goes, whenever a player moves the socket.sessionid and coordinates are send to the server. The server then broadcasts this data to all the other clients except the client which sent the data. In the client-side that information gets decoded and stored in 2 variables (at this moment), a player variable (with the id), and a X variable (with the x value, duh). At this moment I really don't know how to update the positions of a certain sprite in the game. Are there any examples on how to create a basic multiplayer Phaser game using websockets? I'm kinda stuck. The code I'm using on the client side is as follows, it is very dirty atm since I'm experimenting.. The 'xChanged' function sends the new position to the server, and 'posChanged' reads the data that gets sent from the server. var game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, '', { preload: preload, create: create, update: update});function preload() { game.load.spritesheet('player', 'img/ally_sprite.png', 64, 64); game.load.image('boss', 'img/boss.png'); game.load.image('bullet', 'img/bullet.png');}var player, boss, cursors, x, y, z, xTouch, yTouch, fireButton, bullets, bulletTime = 50, text, bulletsCount = 30;var players = {};var io = io.connect('');// server ipvar xPos, yPos, label, sock;function create() { game.renderer.clearBeforeRender = false; game.renderer.roundPixels = true; game.physics.startSystem(Phaser.Physics.ARCADE); player = game.add.sprite(,, 'player'); player.anchor.setTo(.5,.5); player.animations.add('fly');'fly', 10, true); game.physics.enable(player, Phaser.Physics.ARCADE); player.enableBody = true; player.body.collideWorldBounds = true; // new player var pos = JSON.stringify({ player: io.socket.sessionid, x:, y:, angle: 0 }); socket.emit('newPos', pos); boss = game.add.sprite(game.centerX, game.centerY, 'boss'); boss.enableBody = true; boss.physicsBodyType = Phaser.Physics.ARCADE; bullets =; bullets.enableBody = true; bullets.physicsBodyType = Phaser.Physics.ARCADE; bullets.createMultiple(30, 'bullet'); bullets.setAll('anchor.x', 0.5); bullets.setAll('anchor.y', 1); bullets.setAll('outOfBoundsKill', true); game.stage.backgroundColor = '#ccc'; game.input.addPointer(); fireButton = game.input.pointer1; if(isMobile.any) { if(gyro.hasFeature('devicemotion')) { console.log('gyrojs loaded'); if(gyro.getFeatures().length > 0) { gyro.frequency = 10; gyro.startTracking(function(o) { var anglePlayer = Math.atan2(o.y, o.x); angleRadians = anglePlayer * Math.PI/180; anglePlayer *= 180/Math.PI; anglePlayer = 180 - anglePlayer; player.angle = game.math.wrapAngle(anglePlayer, false); if(fireButton.isDown) { fire(); } if(o.z < 9.5 || o.z > 10) { player.body.velocity.x -= o.x * 20; player.body.velocity.y += o.y * 20; } else { player.angle = 0; } console.log(player.body.velocity.x); // Send new position to server var newPos = JSON.stringify({ player: io.socket.sessionid, x: player.body.velocity.x, y: player.body.velocity.y, angle: player.angle }); socket.emit('newPos', newPos); }); } } else { // fallback als gyro.js niet werkt.. console.log('gyrojs not loaded'); window.addEventListener('devicemotion', function(event) { x = event.accelerationIncludingGravity.x; y = event.accelerationIncludingGravity.y; z = event.accelerationIncludingGravity.z; var anglePlayer = Math.atan2(y, x); anglePlayer *= 180/Math.PI; anglePlayer = 180 - anglePlayer; player.angle = game.math.wrapAngle(anglePlayer, false); if(fireButton.isDown) { fire(); } if(z < 9.5 || z > 10) { player.body.velocity.x -= x * 40; player.body.velocity.y += y * 40; } else { player.angle = 0; } // Send new position to server var newPos = JSON.stringify({ player: io.socket.sessionid, x: player.body.velocity.x, y: player.body.velocity.y, angle: player.angle }); socket.emit('newPos', newPos); var interval = 10; }); } } else { // Niet mobiel, bewegingen omzetten in keys console.log('Niet Mobiel'); cursors = game.input.keyboard.createCursorKeys(); } text = game.add.text(, 50, "Bullets: 30", { font: "65px Arial", fill: "#000000", align: "center" }); text.anchor.setTo(0.5, 0.5); // Add new players to the screen socket.on('newPlayerwithPos', function(data) { var obj = JSON.parse(data); var xNew = obj.x; var yNew = obj.y; console.log(xNew, yNew); var p = game.add.sprite(xNew, yNew, 'player'); p.anchor.setTo(.5,.5); p.animations.add('fly');'fly', 10, true); game.physics.enable(p, Phaser.Physics.ARCADE); p.enableBody = true; p.body.collideWorldBounds = true; });}function update() { player.body.velocity.setTo(0,0); if(!isMobile.any) { if(cursors.left.isDown) { player.body.velocity.x -= 40; } else if(cursors.right.isDown) { player.body.velocity.x += 40; var newPos = JSON.stringify({ x: player.x, player: io.socket.sessionid }); } if(game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR).isDown) { fire(); } } // Get new positions from all other players socket.on('updatePos', function(data) { for(var playerData in data) { // update array of players var player = {}; = data[playerData].sessionID; player.x = data[playerData].x; player.y = data[playerData].y; player.angle = data[playerData].angle; players[] = player; } }); // loop through all players and draw sprites for(var playerData in players) { var p = ''; var playerX = players[playerData].x; var playerY = players[playerData].y; var playerAngle = players[playerData].angle; var p = game.add.sprite(playerX, playerY, 'player'); game.physics.enable(p, Phaser.Physics.ARCADE); p.enableBody = true; p.body.velocity.x -= playerX; p.body.velocity..y += playerY; p.angle = playerAngle; }}function fire() { if( > bulletTime) { bullet = bullets.getFirstExists(false); if(bullet) { bullet.reset(player.body.x + 32, player.body.y + 32); bullet.rotation = player.rotation; game.physics.arcade.velocityFromRotation(player.rotation, 400, bullet.body.velocity); bulletTime = + 50; // Update bullet counter bulletsCount --; text.setText("Bullets: " + bulletsCount); } }}
  16. I recently made a game with phaser and noticed that when I press down key the page goes down. Similarly the same happens with up key. Even space key makes the page scroll down. The game gets the keys and works the way it should work but the page also scrolls. This totally ruins the fun. How to handle this situation???
  17. suyashmohan

    [Phaser] Simple Shooter Game

    After knowing about lessmilk, I got so inspired that I too have decided to create a game a week. Atleast I would try to achieve that Here is my first game in this series. It's a very basic simple shooter game made with some free art. I have used Phaser for this game. This may not be a good game but I wanted to atleast begin making games to get the confidence to make more games. The code is available on github. I hope beginners can use it for learning purpose. Play it here
  18. Zef

    [WIP][Phaser] Moon

    Moon is a my first Phaser game... well if I'm entirely honest its pretty much the first proper game I have ever made other than a few experiments here and there. It is a take on the classic Lunar Lander. Its intended for mobiles primarily, and is by no means completely finished. I need to add sound, a loading bar, iron out a few bugs, and add a lot of polish to menus and instructions etc but it is coming along nicely. I am also considering implementing gyroscope controls if possible, but we will have to see how that goes It is pretty hard, I know, and I have actually been slowly decreasing the difficulty although I want to avoid making it too easy. I have used p2 for physics so it is a little performance heavy, but I have tested it on an iPhone 5, iPad mini, iPad 3rd gen, and HTC One all at 60fps so I am fairly pleased. On a very old and clogged up iPhone 4 it was still getting 30+ so not too bad. Anyway you can play it here: Moon I would love to hear what you think, and if you have any suggestion or discover a bug please let me know! Likewise if you have any questions about the game fire away
  19. I am considering getting started with Phaser. I might like to use it in LD29 next weekend. I had question about the performance of geometry in Phaser. When tinkering with the circle geometry example, I set the rendering mode to WebGL. I noticed that basic animations on the circle made it very choppy. I thought that WebGL was typically more performant compared to 2D canvas. Is this only true for displaying raster graphics, or should it apply to generated geometry as well? Just want to make sure this situation wasn't an anomaly for my system. If working with rectangles, circles, lines, and points is meant for 2D canvas, that is fine, I just want to prepare for that going in so that I can get the best performance possible. Thank you in advance for any answers!
  20. Hi there, I´m trying to find something about this but... not working. Anyway, I have two tweens on my game and I need to do that with Phaser.Easing.Elastic.InOut Everything is cool, the only problem is that the "elasticity" is tooo much, I want the animation being elastic but not so much, how can I control that? I don´t know how to use the "example" in the documentation... InOut(k) → {number} Thanks in advance mates!
  21. iamhaas

    Method to clone a sprite?

    Is there a method to clone/duplicate a sprite?
  22. Natman

    [Phaser] Brickety Split

    My first HTML5 game, made in Phaser, has been entered in the "Got Game?" contest for student game developers. If you play it and take the time to leave a rating or review, you directly help my chances of winning, so please play it and rate if you enjoy. Brickety Split The game is about building the tallest wall you can by avoiding bricks that fall from the sky as enemies attempt to trap you. I wrote a detailed post-mortem of my development process. You can read it on my website: And if you have any feedback, please share it. I'm still updating the game and adding suggestions (within reason).
  23. Tanner


    Treedle is a game about lumbering. Player has to chop trees by clicking on them. There are some upgrades and achievements. Play it here: Overview page: Any feedback appreciated! Thanks for your support!
  24. StuffBySpencer

    Help With Tilemaps And Tilesets

    I need help with creating tilemaps. I use tiled to create the maps, however it seems that tiled is counting my tileset image starting at 1, while phaser counts tilesets starting from 0. Because of this, whenever I make a tilemap, the blocks are out of order, and the map looks all screwey. Please help, I have attached an image to better explain this:
  25. mtburdon

    Pass parameter to button callback

    Hi there, I'm trying to do something which I think should be rather simple but I don't seem to be able to achieve it. When a button is clicked, I'm trying to pass a parameter to the button callback function, however if I pass anything to the function and console.log it out, it's always the clicked button. Is there a way to pass a parameter other than the button to the button callback? Thanks! Martin