Math 以三个不同大小的矩形为中心
如果我有3个不同的精灵,每个精灵都属于同一个精灵,但具有不同的动画类型。在“精灵”工作表中,每个都有不同的宽度和高度Math 以三个不同大小的矩形为中心,math,graphics,Math,Graphics,如果我有3个不同的精灵,每个精灵都属于同一个精灵,但具有不同的动画类型。在“精灵”工作表中,每个都有不同的宽度和高度 如何使用数学调整3,使它们居中并相互重叠,以便在我可以更改它们的动画时,所有动画都相互重叠。我想得到每个精灵的x,y,结果它们都有相同的位置。这里是一些伪代码。翻译成你喜欢的语言 Let wi and hi be width and height of ith image, i = 1, 2, 3. Let (x1, y1), ..., (x3, y3) be the coord
如何使用数学调整3,使它们居中并相互重叠,以便在我可以更改它们的动画时,所有动画都相互重叠。我想得到每个精灵的x,y,结果它们都有相同的位置。这里是一些伪代码。翻译成你喜欢的语言
Let wi and hi be width and height of ith image, i = 1, 2, 3.
Let (x1, y1), ..., (x3, y3) be the coordinates of the top left corner of each image.
wmax = max(w1, w2, w3)
hmax = max(h1, h2, h3)
x1 = round((wmax - w1) / 2) // Depending on your language and your purposes, floor or ceil.
y1 = round((hmax - h1) / 2) // Similar comment as x
// Similarly for (x2, y2) and (x3, y3)
// Add offset if necessary
Let (x0, y0) be offset to add to top left corner of image.
(xi, yi) = (xi + x0, yi + y0)
为什么你需要在两个不同的网站上发布@安德里亚,那有什么问题?加梅德夫=谢谢!。Y轴上的所有动画之间仍然有一个微小的偏移。我已经把所有的精灵翻译成了相同的x,y。但仍然有少数像素仅在Y轴上关闭?关闭了多少像素?如果是一,那么可能是因为四舍五入。请注意,如果使用整数除法,则舍入无效。