cykod / Quintus

HTML5 Game Engine
http://html5quintus.com
GNU General Public License v2.0
1.41k stars 401 forks source link

Bug in Q.UI.Container.fit() #115

Closed rohitj closed 10 years ago

rohitj commented 10 years ago

Line 164 and 165 that calculates cx and cy for container after fit() seems to be wrong. Instead of computing the distance between the left most point and the center, it seems to be calculating something completely different.

this.p.cx = -minX + paddingX; this.p.cy = -minY + paddingY;

These should be:

this.p.cx = (maxX - minX) / 2 + paddingX; this.p.cy = (maxY - minY) / 2 + paddingY;

ghost commented 10 years ago

Make a pull request dude

rohitj commented 10 years ago

Sorry! I am glad I started making a pull request. Because then I had to be extra careful, and I realized that I was wrong. minX is computed for objects inside the container. So, -minX (and -minX + paddingX when there is padding) is infact distance of the left most point from the center. Sorry for wasting time.