samme

Members
  • Content Count

    1,994
  • Joined

  • Last visited

  • Days Won

    22

Everything posted by samme

  1. samme

    Get container by name

    Well, it doesn't track them, but it can search them. Phaser.Actions.GetFirst(containers, { name: 'Container1' });
  2. samme

    How do I restart scene?

    Where is buttonGameRestart.addEventListener(…)? Is it inside a scene method?
  3. samme

    Phaser 3 setTextBounds equivalent

    You may not need a boundary for centering: this.add.text(300, 525, "text", style).setOrigin(0.5, 0.5); or Phaser.Display.Align.In.Center(text, this.add.zone(x, y, width, height));
  4. samme

    Sprite gets separate from body

    You can try // After reset(…) game.stage.updateTransform(); game.camera.updateTarget(); game.camera.target.preUpdate() I'm not sure all of those are necessary.
  5. samme

    How do I restart scene?

    Make sure you add the event listener only once, ever. And use the latest stable Phaser.
  6. samme

    Get container by name

    Phaser doesn't track Game Objects by name, but it's pretty easy to do. Remember to empty the list when leaving the scene. var containers = {}; containers[container1.name] = container1; // etc.
  7. samme

    HTML text input within Phaser canvas

    Please check game.renderType.
  8. samme

    HTML text input within Phaser canvas

    What happens? It doesn't, it uses AUTO, which favors WEBGL like before.
  9. samme

    Scalable Game

    I would start with game config { width: 1920, height: 1080, resolution: window.devicePixelRatio || 1 } and then don't use devicePixelRatio ever again. Phaser will handle the resolution and you can just use game-pixel units as usual. The easiest way to fit a smaller display would be to just scale the whole game canvas down (1920 × 1080 → 800 × 450). The hard way is to resize the game canvas, and then scale all the game objects and distances to match. Actually I would try zooming out the camera instead as it could save you a lot of trouble. Try phaser-plugin-game-scale.
  10. samme

    Update group's alpha without a delay

    It may be that the sprites' worldAlpha hasn't been updated yet (because that would happen during the next render). So you could try group.updateTransform().
  11. samme

    Cache sprite created from Phaser.Graphics

    You're right, I was thinking of the BitmapData method. You can do game.cache.addItem('name', Phaser.Cache.TEXTURE); // … game.cache.getItem('name', Phaser.Cache.TEXTURE); But I don't think you'd be able to use the string key alone, because that searches the image cache only.
  12. samme

    delayed overlap animation

    First make sure the animations work like you expect without any collision checking. Just add and play. If the overlap is continuous, you'll be restarting the animation each time. You can use ignoreIfPlaying=true in play().
  13. samme

    Cache sprite created from Phaser.Graphics

    There's a key argument to generateTexture().
  14. samme

    Help with masks

    I think you can use a Render Texture as a Bitmap Mask.
  15. samme

    setBounce does not work when velocity is too high

    Increase physics FPS. At velocity 4000 an object is moving 65px per physics step (at 60fps).
  16. in CANVAS mode you can use RenderTexture#canvas.toDataURL() but in WEBGL mode you need to use the Snapshot Renderer somehow.
  17. samme

    Group Alpha

    Sounds right.
  18. samme

    Rotate Sprite to face a specific coordinate

    Is it that the enemy direction looks wrong? For that you need a texture where the ship is facing rightwards, because that's the direction of rotation=0.
  19. samme

    Sprite with tile texture

    Tilemap#createFromObjects Tilemap#createFromTiles
  20. samme

    Rotate Sprite to face a specific coordinate

    https://photonstorm.github.io/phaser3-docs/Phaser.Math.Angle.html
  21. samme

    Rotate Sprite to face a specific coordinate

    There are Phaser.Math methods to compute the angle between two points or two coordinate pairs. Then you just tween sprite.body.angle.
  22. samme

    Destroy Sprite manually

    GameObject#destroy GameObject#setName()
  23. samme

    Group revive revives at random position

    Normally sprites reappear at the same position as before (because they were just hidden the whole time). How are you killing the barrels?
  24. samme

    CreateFromObjects Displaying Entire Tileset

    You need to add something like this.load.spritesheet('tiles_spritesheet', 'public/images/basictiles.png', /*…*/); and then use that spritesheet key.
  25. samme

    KEYBOARD EVENTS

    Phaser.Scenes.ScenePlugin#pause Phaser.Scenes.ScenePlugin#run