We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CCMenu.alignItemsInColumns
My suggested code change:
/** align items in rows of columns */ public void alignItemsInColumns(params int[] columns) { int[] rows = columns; int height = -5; int row = 0; int rowHeight = 0; int columnsOccupied = 0; int rowColumns; if (m_pChildren != null && m_pChildren.Count > 0) { foreach (CCNode pChild in m_pChildren) { if (null != pChild) { Debug.Assert(row < rows.Length); rowColumns = rows[row]; // can not have zero columns on a row Debug.Assert(rowColumns > 0); float tmp = pChild.contentSize.height; rowHeight = (int)((rowHeight >= tmp) ? rowHeight : tmp); ++columnsOccupied; if (columnsOccupied >= rowColumns) { height += rowHeight + (int)kDefaultPadding; columnsOccupied = 0; rowHeight = 0; ++row; } } } } // check if too many rows/columns for available menu items //assert(! columnsOccupied); CCSize winSize = CCDirector.sharedDirector().getWinSize(); row = 0; rowHeight = 0; rowColumns = 0; float w = 0.0f; float x = 0.0f; float y = (float)(height / 2); if (m_pChildren != null && m_pChildren.Count > 0) { foreach (CCNode pChild in m_pChildren) { if (pChild != null) { if (rowColumns == 0) { rowColumns = rows[row]; if (rowColumns == 0) { throw (new ArgumentException("Can not have a zero column size for a row.")); } w = (winSize.width - 2 * kDefaultPadding) / rowColumns; // 1 + rowColumns x = w/2f; // center of column } float tmp = pChild.contentSize.height*pChild.scaleY; rowHeight = (int)((rowHeight >= tmp) ? rowHeight : tmp); pChild.position = new CCPoint(kDefaultPadding + x - (winSize.width - 2*kDefaultPadding) / 2, y - pChild.contentSize.height*pChild.scaleY / 2); x += w; ++columnsOccupied; if (columnsOccupied >= rowColumns) { y -= rowHeight + 5; columnsOccupied = 0; rowColumns = 0; rowHeight = 0; ++row; } } } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
CCMenu.alignItemsInColumns
My suggested code change:
The text was updated successfully, but these errors were encountered: