Relocate the center of a layer

Hello and merry X Mas,

currently I am trying to port an old godot prototype to gdevelop, that I really like so far. But I have a small problem that drives me nuts. Basically I want to rotate a layer at a different location then the center. That would be kind of an abstract.

So in more detail. In my game I use several layers to put the player in a race track of a square that is located in the 1/3 upper screen.

The blue square is a blue test square and you see some random generated white squares on a layer in the background. It rotates. But it rotates around the center of the layer, not around the square where I will count points. I could use an object, but later on there will be some movement on the layer, so I really want -like in godot or other engines- treat the layer like a node and give it another anchor or another center.

First I started out with a arranging my elements like they should look to the player at the end, meaning my “playing field” is in the upper 1/3 of the screen and not centered. When I figured out it is not possible in gdevelop to relocate layers, I put everything to the center and thought I could handle it via moving the layer cameras.

Then followed some attempts with camera following objects (bluetestssquare) and some weird other ideas. I hope I could describe the problem good enough, otherwise I will give another attempt later. Basically the Blue Test Square placed in the middle of its layer should rotate behind the Square that shows the 1.

PS: I am also open to some javascript “hacks”

PS2: I attached a reduced version of my problem

I hope someone experienced helps you.


As far as I know, you can’t change the center of a layer.

Assuming that you need these objects to rotate from the center as in rotating the whole camera for the layer, then why not try this solution that requires the sprite snapshot extension?

Solution
  1. Center all layers, and render the scene to a sprite (rectangular sprite with the same size ratio as the game resolution)

  2. Hide all of these layers and show the layer that contains the sprite.

  3. To achieve the offset you want, move the sprite you rendered to the position you want


I am not sure if this is what you want, you are not being clear.

You could use sin() and cos() but XFromAngleAndDistance() and YFromAngleAndDistance () do the same with less math. It would be similar to the put around position

I’m not clear on your goal. You’ll need to take a lot into account like layer/camera positions and distances between objects and/or layers.

1 Like