• Content Count

  • Joined

  • Last visited

  1. I am trying to get a particle emitter work in the middle of a screen where the camera is moving around on the map (like a win animation thingy), but I can't get it working. I can get the particles to work but they are stuck to specific coordinates and not centered in the screen/camera. I can't set scrollFactor on particles and if I add it to a container with scrollFactor(0) then I get this error: Uncaught TypeError: child.setScrollFactor is not a function at ContainerWebGLRenderer [as renderWebGL] (ContainerWebGLRenderer.js:59) at WebGLRenderer.render (WebGLRenderer.js:1563) at CameraManager.render (CameraManager.js:409) at Systems.render (Systems.js:298) at SceneManager.render (SceneManager.js:587) at Game.step (Game.js:450) at TimeStep.step (TimeStep.js:553) at step (RequestAnimationFrame.js:102) Anyone has any ideas on how to achieve this?
  2. I currently use two patterns to avoid having a large monolithic class with all logic. I have tried to extend Sprite and also to just have a class that includes all the objects in it. I am still not sure what the best approach is. Basically the new class is often what you would consider a Container I think so it might make more sense to actually extend Container instead of Sprite. For extending Sprite I do something this (incomplete code but you get the idea): export default class Enemy extends Phaser.GameObjects.Sprite { constructor (config) { super(config.scene, config.x, config.y, config.key); config.scene.add.existing(this); } I am pretty much a noob in Phaser and not very experience in Java/TypeScript either so I don't know if this is a good approach or not. But it works for me so far
  3. I am playing around with this.scene.cameras.main.scrollX now, it seems to give me the current scroll offset relative to the world and from that I can add the container position etc. So I think this will work. I tried getWorldPoint as well and it gives me the same result (for camera position). It would be nice with some more intuitive way of doing it though 😃
  4. I can use the container.x & .y but it doesn't really work in my case. The container is drawn with scrollFactor 0, so when the camera moves the container does not move relative to the camera, but it does relative to the world. Thus the real world coordinates changes when the camera moves but the x & y fields in the container does not seem to update with the camera (they are what they were set to originally). Example: Initially the container is placed at 0,0. Then the player and camera scrolls 200px to the right. Now the real world position of the container is 200,0 but .x,.y still says 0,0. Hope that makes sense! 😃
  5. How can I get the absolute position of a Sprite or Image in the world? I have a Sprite that is inside a container with scrollFactor of 0 and I want to move other sprites outside the container to that position. Basically this question but for Phaser 3 =) -
  6. Is anyone using Phaser 3 with TypeScript for any serious project? I am trying it out now, but it seems that some methods that are available in JavaScript are not recognized by the typings definition, e.g. Phaser.scene.load.spritesheet(...) So I am worried that maybe using TypeScript is not an option?
  7. Hi, does anyone know if there are any typings file for Phaser 3.9.0 available anywhere?