How do I rotate multiple bricks/sprites side by side?

Hi,

I have multiple sprites, like a brick wall.
I want to rotate the first left bottom sprite/brick and all the others bricks of the wall like in this picture with any rotation angle from 0 to 360 :


The wall should be the same after rotation, just like rotating a photo of sprites instead of pixels.

What’s the easiest way to do that ?

I tried to put all the sprites in a layer and rotate the camera but i lost the collisions.
I tried to rotate each sprites but the center of rotation is the center of each sprite so i need to rebuild all the wall after rotation.

Thanks.

Does each brick look the same? Could you do a tiled sprite and then rotate the whole thing?

No it’s a quite complex sprite wall. It’s like a plateform with objects on it and you want to rotate the whole thing.

Is there a very good reason for the wall not to be a single sprite? :grin:

The Physics behavior allows to choose any point as mass center, that might help you.

A single sprite is not possible. Maybe the explanation of my problem was too simple with this “wall” thing, i wanted to do simple because my english is bad. There are multiple sprites stuck together. They all can move and change size, animation,… It’s quite complex, like if i wanted to rotate a platform of a plateformer game with sprites on it. That’s why at first i tried to put all that in a layer. I’m looking for a container or a mecanism like that to rotate all sprites in 1 move.

The problem is you’re not rotating your sprites on one of their axis, you’re trying to rotate all of the sprites based on the axis of ONE sprite.

I’m not sure if you can do that normally. Maybe via the “Pin an object to another object” events? M

Here’s a solution that seems to work:


In the beginning:

image


After one click :

image

After another click :

image

After yet another click :

image

5 Likes

You can also use the “parent” sprite with points. Then assign the x and y coordinates of the “children” sprites to the points. As a result, when you rotate the “parent” sprite, the coordinates of the points, and, accordingly, the coordinates of the “children” sprites will be saved. Seems to be the easiest way

You could check out this example that has a parent and a child. And you can use A and S to rotate both. The child will be rotating around the parent, GDevelop 5

How would you go about adding points at run time? Can we do that in GDevelop?

It seems the points can only be added previously

Thx MrMen, i did a quick test it’s working when sprites are not moving. Now i need to figure out how i can deal with moving sprites, thx again. :blush:
Thx Midhil too i will try the parent thing too.

Perhaps I did not explain the point method well, here is an example: https://drive.google.com/file/d/15mF2nOfRf-Wc1uF7jIrfvn9xRr8eMqjm/view?usp=drivesdk

Ah, the old shifting goal posts/scope creep :smiley: . This thread has given you a few ways of doing it, it’ll be a matter of figuring out which one is most suitable.

Your explanation was fine. The only downside I see with the points method is that it doesn’t scale - it’s limited to however many points you define in the editor.

1 Like

Thx all, that’s work well now with less code :sunglasses: