J4G

Members
  • Content Count

    29
  • Joined

  • Last visited

  1. Do you think that P2 is the best library for Phaser integration? http://brm.io/matter-js/ and http://wellcaffeinated.net/PhysicsJS/ seem to get more attention. It's also really hard to manage collision groups - the whole flow of that feels pretty unnatural for anything remotely complex.
  2. Both. I did a lot of performance testing and most of the issue was with P2, but I had to do a *lot* of render optimization to get the draw times down - and even then they were around 8 ms.
  3. I'm kinda at a loss with this one. I had a game with a procedurally generated 100x100 tilemap (but rendered as individual sprites), sometimes with 2 or 3 sprites per location. It's a shooter so I needed more complex physics interactions than Arcade's rectangle-on-rectangle collisions, so there were lots of P2 bodies. I spent weeks trying to optimize it and I eventually had to give up - I just couldn't get it to perform. I tried the same demo in Unity and it ran flawlessly. I know JS can't be expected to have Unity's performance, but v8 is more than 20fps fast. I have no special love for Unity - I'd love to code everything in Phaser, but I dunno what new approaches I can try or where Phaser is lacking. Thanks for all of your work - I'd love to see Phaser 3 at a point where I can attempt ambitious projects like this.
  4. I don't think P2 has support for sensors, or it's not in the documentation. I'd be fine with destroying bodies expect it seems to be a pretty computationally expensive operation.
  5. I have a tile-based world around 10,000 tiles big. Each tile has a static physics body that needs to interact with bullets of varying shapes as well as a rectangular player. In theory I could get by with just rectangular and circular hitboxes (so Arcade is out of the question), but Ninja is deprecated so I'm not really interested in using it. Right now I'm sitting at around 5 ms of P2 processing time, which is impressive but still too heavy for my use case (I'm developing on a pretty good computer). I've tried various techniques of optimization, including destroying off-screen sprites, but that operation is pretty expensive. I'm not sure if the problems I'm encountering can be resolved by using a library other than P2, or if it's just an impossible problem due to the amount of computation required. I'd love to hear some input on this from others.
  6. I realized I'm never doing that because the sprites inherit physics from a parent group. Can I run that "add body" line without duplicating anything?
  7. If you want simple rectangle collison, just check if (Phaser.Rectangle.intersects(sprite1.getBounds(), sprite2.getBounds())) each frame. This should work regardless of the physics engine. It's pretty cheap, too.
  8. I'm using P2 physics in a game and the "sprite" attribute of the P2 physics body is very important to me when handling collision callbacks. Unfortunately, all of them are set to "null" for whatever reason, making it impossible for me to access information about the parent sprite of a body. Is anyone else having this problem?
  9. I'm creating a game where, by necessity, each of my tiles exists as a sprite within a group. They all use P2 Physics for collisions. I'm careful to set each sprite to static, and then configure them like so this.sprite.body.setRectangle(TILE_WIDTH, TILE_HEIGHT) this.sprite.body.static = true; this.sprite.body.x = this.x * TILE_WIDTH + (TILE_WIDTH / 2); this.sprite.body.y = this.y * TILE_HEIGHT + (TILE_HEIGHT / 2); But the locations of the bodies are ever so slightly off, usually by around .0000001, and it looks like this error is applied on every update cycle in spite of my efforts. Now you wouldn't think such a minor change would affect things, but it actually leads to rounding errors causing vertical black lines between tiles. Is this a bug, or are there changes I can make to my code to resolve this?
  10. J4G

    Phaser pan audio

    Is there any way to use Phaser's built-in sound management to "position" sounds within stereo channels or even 5.1 if possible? I know WebAudio supports it, but I don't see anything like that in Phaser's documentation.
  11. I ended up just flooring my calculated x value for each tile. It wasn't what I originally intended, but it seems to be working just fine!
  12. I'm not using TileMap, I'm placing them individually. I'm not entirely sure what you're suggesting with the overlap, could you clarify? Currently the placement of the vertical lines changes depending on the scaling of the individual tiles.
  13. I'm creating a tile-based game where the game is set to always have ten tiles vertically and scale every tile to fit as such. At certain window sizes, however, there are gaps every few tiles running vertically. Strangely enough these lines only run vertically and not horizontally. I'm assuming this is because of the non-round scaling (a typical number is something like 2.496875). Any ideas how to fix this?
  14. Thanks for the responses, both of you. I guess I'll probably just change the way I manage my spritesheets.