• Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by samme

  1. Hi deedee, If you want to use game.state.restart(), move this.garbage = []; this.lifeSprites = []; into your BasicGame.Game.prototype.create() function. In fact you probably want to move all the State properties that might change during the game session (and should be reset when restarting) there too. game.state.restart() runs the state's create() method again. It doesn't reinitialize the state, so the constructor BasicGame.Game() is never run again.
  2. Ah I found it, there's Math.getShortestAngle() in Phaser 2.7.
  3. Also: You don't need to enable physics on emitters; the particles already have physics bodies. I can't tell if coin.coin is a Sprite or an Emitter, but you can test overlaps on the emitter itself. It will loop through all the particles: game.physics.arcade.overlap(player.coinCol, coinEmitter, function(coinCol, coinParticle) { // … }, null, this);
  4. I know it sounds crazy but body.rotation and sprite.rotation are different. The assignment in Arcade.Body is wrong but Arcade.Body#preUpdate is correct.
  5. That looks about right. I would use body.rotation just to be consistent. And you can take the absolute value just once. body = gameObject.body; var angleDistance = body.rotation - newAngle; var turnTime = Math.abs((angleDistance / body.angularVelocity) * 1000); But I think the sign of angleDistance must matter somehow since it implies the direction of the turn. Maybe try to make a quick example w/ .
  6. Are you using arcade.collide or arcade.overlap? collide should separate the two bodies so they collide for only 1 frame. For arcade.overlap, Phaser doesn't trigger anything when the overlap ends, but you can track it yourself with body.touching.none and body.wasTouching.none.
  7. Hi feudalwars, body.angularVelocity, body.maxAngular, and body.rotation are actually in degrees, not radians (the docs are wrong there). sprite.rotation is in radians. I'd thought there was a Phaser function giving the smallest difference of two angles but I can't find it now. When angles wrap the absolute difference may not be the smallest one: e.g., from 359° to 1° should be +2° (clockwise), not -358° (anticlockwise).
  8. You should try Chrome's CPU profiler. Here's a desktop profile:
  9. The invisible sprite method is good. I've also used var distanceBetween = Phaser.Physics.Arcade.prototype.distanceBetween; Phaser.Physics.Arcade.Body.prototype.distanceTo = function(target) { return distanceBetween(,; }; Phaser.Physics.Arcade.Body.prototype.isBeyond = function(range, target) { return this.distanceTo(target) > range; }; Phaser.Physics.Arcade.Body.prototype.isWithin = function(range, target) { return this.distanceTo(target) <= range; };
  10. Hi symof, I mean that the shadow should be clipped to the asteroid (panels 6–7) instead of overflowing it (panels 3–4). It's like but I need to rotate the mask continuously without rotating the shadow texture beneath it.
  11. (1) an asteroid texture (2) a shadow texture (3) shadow covers asteroid (4) asteroid rotates but shadow doesn't shadow clips to asteroid's outline (5, 6) at its current rotation (7) end result I'm stuck at #5–6. Ideas?
  12. Glue is neat. glue ./images ./atlas --json # -> atlas/images.png # -> atlas/images.json # Descend into folders: glue ./images ./atlas --json --recursive # Make 1 atlas per folder: glue ./images ./atlas --json --project
  13. Done!
  14. Sure, post the modified source.
  15. I believe there's game.physics.arcade.checkCollision.bottom = false; = false;
  16. Now with filter and map: game.debug.graph(obj, { // options: collapse: true, filter: null, // function (obj) -> true || false map: null, // function (obj) -> "description" skipDead: false, skipNonexisting: false });
  17. Now with blocked, touching, and bodyDisabled.
  18. Here's a snippet to quickly look at a running game (run in console): ( || Phaser.GAMES[0]).load.script("SceneGraph", "", function (){; }).start();
  19. Draws properties of Arcade Physics bodies. Demo / Code npm i phaser-plugin-debug-arcade-physics
  20. Prints Phaser’s display tree. Demo / GitHub / NPM npm i phaser-plugin-scene-graph