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
    • 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

Found 3,231 results

  1. World bounds in P2JS

    Here again. My circles are ignoring world bounds. So there is code:, 0, WINDOW_WIDTH, WINDOW_HEIGHT);; = 0.8;;//...////...////...//chipsCollisionGroup =;this.chips =;this.chips.enableBody = true;this.chips.physicsBodyType = Phaser.Physics.P2JS;//...////...////...//function setupChip(chip, owner, game) { if (chipsCount[owner] < 1) return false; var MAX_MASS = 6; var mass = Math.ceil(Math.random() * (MAX_MASS - 1)) + 1; chip.scale.setTo(convertY(CHIP_SIZE / MAX_MASS * mass) / 64); chip.mass = mass * 100; chip.anchor.setTo(0.5, 0.5); chip.tint = PLAYERS_COLORS[owner]; chip.owner = owner; chip.dragging = false; chip.body.setCollisionGroup(chipsCollisionGroup); chip.body.collides(chipsCollisionGroup); chip.body.setCircle(chip.width / 2); chip.inputEnabled = true; chip.input.start(0, true);;; return true;}//Usally previous function calls like thisvar chip = state.chips.create(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, 'chip');setupChip(chip, PLAYER_FIRST,;
  2. Circle physics

    Hello! I tried to make my game with physics. Prototype you can find here. First goes blue, than red, green, yellow. You can't win or lose, yet. As you can see, I use circles, but I use Phaser.Physics.ARCADE too and it doesn't support circles, so now there're squares instead of circles. How can I fix it? .Sorry for bad english
  3. How to Ride a Moving Sprite?

    Does anyone have an idea of how my player can "ride" a moving sprite. I want to jump on a horizontally moving block and my player to remain fixed in place on the block. Currently (with simple collision working) the block moves out from under the player. If anyone can point me in the right direction, I'd be grateful.
  4. Ragdoll Using P2.

    Hi, I have recently used phaser and p2 for a university project. Just wondering if anyone would be interested in an example if I put one together? Also, do you think this is something that would interest the guys at Phaser to the point where they could maybe post it in the examples? I used the P2 example from schteppe's Github and had a little help from him too. I would have to work to make it better to show it as an example, but its not bad. Had a little trouble with the scale of physics, tried setting the overall mass to 80 units(whatever they may be) and the gravity to 10 and it did not work, so think I have to figure out the physics units. Tried the pixel to p2 unit conversions with no luck either. I am willing to put in a bit of effort and make a reasonable example if it interests people. Here's a very buggy quick demo, had just finished ragdoll but not implemented any game features. As I said needs work, but let me know if anyones interested as I dont fancie putting in the work for no reason! Cheers.
  5. Dotted line

    Hi again! Is there any way to draw dotted line, except sprite and many small lines?
  6. Just released my first game at It's an endless runner. Croaking, jumping and splashing. It's a bit rough around the edges and needs some fine tuning, too. Feedback appreciated. Updates: 1.1.0 Added 2 game modes (Time Attack, 30 Jumps). 3 in total now.Added Leaderboards (separate board for each game mode)Added a separate Score-Screen.Added smooth screen transition effect.
  7. P2 collisions refuse to cooperate

    I'm very new to Phaser (<1 week) but I've stared at the examples and I think it really looks as if I'm doing the right thing, yet collisions refuse to work. In my gameState.create I run the following to set up my P2-physics: game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.setImpactEvents(true); game.physics.p2.restitution = 0.8;, -300, 8200, 20000); this.playerCG = game.physics.p2.createCollisionGroup(); this.enemiesCG = game.physics.p2.createCollisionGroup(); this.groundCG = game.physics.p2.createCollisionGroup(); game.physics.p2.updateBoundsCollisionGroup();and later adding the player: this.player = game.add.existing( new Player(this, game, 750, 180, 0)); game.physics.p2.enable(this.player); this.player.body.setCollisionGroup(this.playerCG); this.player.body.collides(this.groundCG, this.player.collidesGround, this); this.player.body.collides(this.enemiesCG); my grounds are the 'fistulaeHair' and are added: game.physics.p2.enable(fistulaHair); fistulaHair.body.kinematic = true; this.ground.add(fistulaHair); fistulaHair.body.setCollisionGroup(this.groundCG); I'm expecting this.player.collidesGround to be called when flying into the ground but nothing happens: It doesn't collide the the collidesGround has a console.log as first line which never fires. I must be missing something very basic it feels like. Also, as a side question, how do I test if I hit the world-end in P2-physics? Any help much appreciated.
  8. Falling Through Moving Blocks

    Friends, I'm having an issue with my player falling through blocks which move -- in this case vertically -- but only in Firefox (29.0). Chrome 34+ and IE11+ seem to be fine. It doesn't seem to happen under any clear circumstances. Sometime it is while jumping, stepping left/right, or just standing still. (Player bounce is not enabled, however the player does seem to bounce on the blocks as they descend. This could be an issue.) Code: Game: Any ideas?
  9. As you can see from this Fiddle, the change from 2.0.3 to 2.0.4 breaks game.stage.backgroundColorHow can I fix this?
  10. Hi all, So I'm trying to add background music to my game, and I've provided phaser with a .ogg and a .mp3 file so it has a fallback. Problem is, the audio doesn't play/load at all in Google Chrome (latest build). In Firefox the audio is working fine for me. I've looked at some examples on and added the audio the same way they did there, like this:'backgroundMusic', ['assets/audio/TakingFlight.mp3', 'assets/audio/TakingFlight.ogg']);Later in the javascript I play the music using this code: backgroundMusic ='backgroundMusic');'', 0, 1, true);Any suggestions / ideas? I've added the mp3 file of the background music in this post, wasn't allowed to upload the ogg.. TakingFlight.mp3
  11. Change sprite color

    Hello! Just started to learn phaser and have a question: I have a gray sprite, how can I make it draw blue and after some event make it red? I tried to find it but haven't any progress. If there're no solutions, all task: I want to make blue circles with physics body and if circle is colise with another - change color of both to red. Thanks. Sorry, for bad english :|
  12. Hi! I have a strange behavior: when I start game first time on mobile browser (with clear cache) it runs very slow. But when I reload page it performs much better. May be someone faced with similar. [EDIT] I've tested on chrome & safari, it occurs only in chrome. [EDIT2] Oh, looks like this is random thing, depends on device's processor loading..
  13. Levitation with P2 Physics

    Hello! I´m newbie in Phaser and game programming, And I want to make a open air artillery game. I want the characters to have a up and down movement as if it they were levitating and I was wondering what was the best way to do it with P2 since it will be a artillery game and i'd like to see the characters react to the physical impact of projectiles while levitating. Sorry for any misuse of english (not my native language) and thanks!
  14. Hello! I am 27thColt. This is my first game that I have ever made! It is called Floater (couldn't think of better names). You are a Scuba Diver avoiding fish and collecting coins and bubbles! Here is the link: Here are some pictures: If you want, here is the repository: Just don't steal my code guys, it's not cool. Hopy you enjoy the game!
  15. Camera Issues - Vertical Climbing Game

    Dear Phaser Phriends, I'm trying to figure out how to get a camera to follow the player as he climbs vertically. Also, I want the camera to follow a players descent properly so that when the player returns to his starting y-value, the camera goes back to where it was at game load (in this case, showing the ground completely). Currently there are 2 problems: 1. The camera only follows the player vertically (or moves up) when the player is moving outside the vertical game boundary. The camera should ideally begin its ascent when the player reaches the fourth block from the ground. 2. When the player descends, the camera remains above the ground level. I'd like the camera to return to its default location when the player is at his starting y-value position. Example: Source: * Note: I have read the source code for cameras, but I'm still learning how to read/write code, as I'm sure is clear by my own code.
  16. 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); } }
  17. 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
  18. 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?
  19. 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?
  20. 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.
  21. Why do p2 sprites in a group collide with each other when collideWorldBounds=true but when I set it to false they stop colliding?
  22. 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?
  23. 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
  24. 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!
  25. 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.