我有一堆具有以下属性的对象:
xPos = x coordinate of position in world
yPos = y coordinate of position in world
size = size of object
我有一个函数可以将这些对象绘制到屏幕上。屏幕有一个 x 偏移量和 y 偏移量,因此用户可以平移并且对象将根据需要在屏幕上移动。这一切都很完美。现在我想添加放大和缩小的功能,但我不知道如何对位置应用缩放。
render(int xOff, int yOff, int zoom){
int x = xPos + xOff;
int y = yPos + yOff;
s->addRenderJob(texID, x, y, size * zoom, size * zoom);
}
缩放对象的大小很简单,但是如何通过缩放修改x和y位置,使对象之间的距离也乘以缩放?
最佳答案
render(int xOff, int yOff, int zoom){
int x = xPos + xOff;
int y = yPos + yOff;
s->addRenderJob(texID, x* zoom, y* zoom, size * zoom, size * zoom);
}
如有需要,您可以下载游戏引擎。 研究如何处理游戏中的坐标系。
关于c++ - 我如何将缩放合并到这个坐标系中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31307561/