CCPolygonShape* CCPolygonShape::create(CCPoint* vertices, unsigned int numVertices) { CCPolygonShape* polygon = new CCPolygonShape(); polygon->initWithVertices(vertices, numVertices); polygon->autorelease(); return polygon; }
CCPolygonShape* CCPolygonShape::create(cocos2d::CCArray *vertices, bool fill, bool close) { CCAssert(vertices->count() > 0, "vertices->count() > 0"); CCPolygonShape* polygon = new CCPolygonShape(); polygon->m_numberOfVertices = vertices->count(); polygon->m_vertices = new CCPoint[polygon->m_numberOfVertices]; polygon->m_verticesDraw = new CCPoint[polygon->m_numberOfVertices]; for (unsigned int i = 0; i < polygon->m_numberOfVertices; ++i) { CCPoint* pt = static_cast<CCPoint*>(vertices->objectAtIndex(i)); polygon->m_vertices[i] = *pt; polygon->m_verticesDraw[i] = *pt; } polygon->m_fill = fill; polygon->m_close = close; polygon->autorelease(); return polygon; }