• Content Count

  • Joined

  • Last visited

Everything posted by Reicher

  1. I’m trying to make a game with a rocket ship navigating in a cave. The cave is broken up into 400x400 big tiles that’s combined to form a bigger cave. They all have physics-maps from “PhysicsEditor” that seems to work correctly. My tileclass: export default class Tile extends Phaser.Physics.Matter.Sprite { constructor(scene, x, y, sprite, phymap) { super(, x, y, sprite, 0, { shape: phymap }); this.setStatic(true); this.setBounce(0.05); scene.add.existing(this); } } And these are added in game.js: tilemap[1][0] = new Tile(this, 0, 0, 'ground', tile_body.ground) tilemap[0][0] = new Tile(this, -400, 0, 'bottom-left', tile_body.bottom_left) tilemap[0][1] = new Tile(this, -400, -400, 'vertical', tile_body.vertical) But the tiles are all over the place, if I set them all on position (0, 0) you can see it more clearly: Any ideas to what I am doing wrong? I thought all would be on top of each other if created at position (0, 0) with the same height and width?
  2. I'm down the exact same path you where a year ago, @Neomak. I managed to got what you have without any errors now, but I haven't got an gravity at all. The Phaser 3 example with simplified gravity works nice but with your code I don't see any effect. My game config: const config = { type: Phaser.AUTO, parent: "phaser-example", width: 400, height: 700, physics: { default: 'matter', matter: { gravity: { x: 0, y: 0 }, plugins: { attractors: true }, debug: true } }, scene: [ BootScene, SplashScene, MainMenuScene, GameScene, HUD] }; If i remove the gravity-part I get weird warping anti-gravity.. My attractor planet code: export default class Planet extends Phaser.Physics.Matter.Image { constructor(scene, x, y) { super(, x, y, 'planet', null, { shape: { type: 'circle', radius: 150 }, plugin: { attractors: [Phaser.Physics.Matter.Matter.Plugin.resolve("matter-attractors").Attractors.gravity] } }); this.setStatic(true); this.setBounce(0.05); this.setFriction(1); this.setMass(10000000000); scene.add.existing(this); } } Here tried with a looot of mass and also tried all masses default. Any help would be much appriciated.
  3. I'm working on a little game( that uses Phaser 2.3.0. In my game i have a chain of connected lines segments (Phaser.Line). I want to detect when any of these segments intersect. I have found a problem with how Phaser.Line.intersects work. A simple example: var line1 = new Phaser.Line(0, 0, 100, 0); var line2 = new Phaser.Line(40, 0, 60, 0); console.log(line1.intersects(line2)); console.log(line2.intersects(line1)); The two segments line1 and line2 are not only parallel but also on top of each other. Phaser.Line.intersects does not recognize this type of intersection. I understand that in a pure "math-sense" parallel lines cannot intersect or rather they do intersect on infinite many places. What is the easiest way to detect the "intersection"? Keep in mind that I have many lines in my game and need a general solution.
  4. Hi! I'm really starting to get into Phaser and would like to know it better. I have a couple of of bodies in a group, they all fall down nicely with the arcade physics. But I want to rotate them around a center point. I do this by tweening the group, the rotation looks great but once it's done they moving (falling?) in weird directions. A theory in #phaserio on freenode was that the bodies are still falling down relative to the group down? Why are they not falling down in the "world's down"? this.physics.startSystem(Phaser.Physics.this.physics.arcade.gravity.y = var aGroup =;aGroup.x =;aGroup.y =;var sprite = aGroup.create(-100, 0, 'phaser');sprite.anchor.set(0.5);this.physics.arcade.enable(sprite); var sprite2 = aGroup.create(100, 0, 'phaser');sprite2.anchor.set(0.5);this.physics.arcade.enable(sprite2); var tween = this.add.tween(aGroup).to ( {angle: '-90' }, 500, Phaser.Easing.Linear.None, true); Example on pastebin: Am I doing something wrong or is this how it's supposed to behave? How could you do this any other way?
  5. Of course! I haven't been playing around with Phaser long enough to realize you could tween whole groups. That's exactly what I needed:) Thanks a lot!
  6. Hi! I'm new to Phaser and are trying to make a simple game in which you can rotate the game board (90 degree steps). on the board there's a a few blocks that should be rotated along with the board. To rotate the board and the blocks around their center anchor points work well with tweens but I haven't managed to get the blocks to rotate nicely along with the board as described in the picture. So far my best solution is to tween the block positions but that doesn't look very good. var goal = new Phaser.Point(this._block.x, this._block.y);goal.rotate(this._center.x, this._center.y, -90, true);this.add.tween(this._block).to({x: goal.x, y: goal.y}, 750, Phaser.Easing.Linear.None, true, 100); I guess i could set the anchor point of each block to the center and then rotate, but how do I translate the board center position to the anchor point format? I could calculate a few points in an arc and interpolate between them. I also heard about tweening in bezier curves. Al this sounds like a bit of overkill, there must be an easier way? My first 10 Google pages are all purple