Translate inner position of rotating container into absolute position

Hi! im new to Phaser, and now facing some embarrasing problem.

I have a Player, which can move in any 2D direction, and also able to rotate around its center, depending on a cursor position. Now i need to create bullets, which must appear in front of player according to its angle. Here’s some code:

 // Create a container and sprite
this.container = this.scene.add.container(x, y); 
this.sprite = this.scene.add.sprite(0, 0, this.ship.spriteKey);
this.sprite.setScale(this.ship.scaleX, this.ship.scaleY);

// Add sprite to container
this.container.add(this.sprite);

// Adjust container size and enable physics
this.container.setSize(this.sprite.displayWidth, this.sprite.displayHeight);
this.scene.physics.world.enable(this.container);

This code is located in custom Player class, which has its own scope with link to current Scene.

The Player’s sprite added as a child of it’s container, because i’m also need to add several other sprites to it, which must move and rotate in the same way as the Player itself.

The problem is I can’t get how to calculate the absolute position of point in front of Player to use it as a starting point of bullets. Actually. I can get it, using the absolute position of Player’s container and its inner position, but it works only if the container won’t rotate, so i have to also depend on container’s rotation.

One of conditions is this point must be not a child of Player’s container - this is the pain.

Now I have only one idea, how to do it. At start of the game I can create an invisible point, which will have origin position equal to container’s origin, and I have to manually update this point position and rotation equal to container whenever the Player moves or rotates. I think it should work, but in my opinion it is a kind of a “dirty” solution.

So, is there any right and elegant way to translate rotating container’s inner position into absolute position? Thanks.

Sorry for my poor english :slight_smile: