LibGDX - Rotate a 2d array of sprites around their center

江枫思渺然 提交于 2019-12-02 07:41:17

the first thing that comes to mind is, if I understand your question, you tell all sprites where is the point which must rotate using: sprite.setOrigin(yourPointVector2.x, yourPointVector2.y); sprite.rotation(yourRotation);

Edit new edited for your comment

simple test for 1 sprite rotation, maybe is not the best way but it occurred to me that right now.

Like this helps you, if your sprite is at 50.50, of the your map, and the center of your map is 400, 240, I would create a variable that will store the initial position of the sprite,

example:

//is stored only once, because if not will store where you are during rotation

yourVectorPosInicial.x = sprite.getX();
yourVectorPosInicial.v = sprite.getY();

yourVectorCenterMap.x = 400f;
yourVectorCenterMap.y = 240f;` 

youtSprite.setOrigin(yourVectorCenterMap.x-yourVectorPosInicial.x , 
                     yourVectorCenterMap.y-yourVectorPosInicial.y);

//this in your Draw or update render

sprite.rotation(10f);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!