From 41e2d841160c7cb21731024a953cb2c96ec48e24 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 28 Apr 2015 10:35:21 +0800 Subject: [PATCH] Fixed compile error on VS 2012. --- cocos/2d/SpritePolygon.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cocos/2d/SpritePolygon.cpp b/cocos/2d/SpritePolygon.cpp index 3609156a2b..71f51b3118 100644 --- a/cocos/2d/SpritePolygon.cpp +++ b/cocos/2d/SpritePolygon.cpp @@ -209,7 +209,8 @@ TrianglesCommand::Triangles SpritePolygon::triangulate(std::vectorpush_back(V3F_C4B_T2F{v3,c4b,t2f}); + V3F_C4B_T2F vert = {v3,c4b,t2f}; + _verts->push_back(vert); _indices->push_back(idx); idx++; } @@ -220,7 +221,9 @@ TrianglesCommand::Triangles SpritePolygon::triangulate(std::vectorsize(), (ssize_t)_indices->size()}; + + TrianglesCommand::Triangles triangles = {&(*_verts)[0], &(*_indices)[0], (ssize_t)_verts->size(), (ssize_t)_indices->size()}; + return triangles; } bool SpritePolygon::initWithCache(const std::string &file, SpritePolygonInfo *info) { @@ -331,14 +334,15 @@ bool SpritePolygon::initWithVerts(const std::string& filename,std::vectorgetContentScaleFactor()); setAnchorPoint(Vec2(0.5,0.5)); _transformDirty = true; - auto _triangles = TrianglesCommand::Triangles{&verts[0], &indices[0], (ssize_t)verts.size(), (ssize_t)indices.size()}; - _polygonInfo = SpritePolygonCache::getInstance()->addSpritePolygonCache(filename, _textureRect, _triangles); + TrianglesCommand::Triangles triangles = {&verts[0], &indices[0], (ssize_t)verts.size(), (ssize_t)indices.size()}; + _polygonInfo = SpritePolygonCache::getInstance()->addSpritePolygonCache(filename, _textureRect, triangles); #if CC_SPRITE_DEBUG_DRAW debugDraw(); #endif return true; } + bool SpritePolygon::initWithRect(const std::string& filename, std::vector& verts, std::vector& indices, const cocos2d::Rect& rect) { CCASSERT(filename.size()>0, "Invalid filename for sprite"); @@ -352,11 +356,12 @@ bool SpritePolygon::initWithRect(const std::string& filename, std::vectorx, it->y, 0); auto c4b = Color4B::WHITE; auto t2f = Tex2F(0,0); - _verts.push_back(V3F_C4B_T2F{v3,c4b,t2f}); + V3F_C4B_T2F vert = {v3,c4b,t2f}; + _verts.push_back(vert); } - auto _triangles = TrianglesCommand::Triangles{&_verts[0], &indices[0], (ssize_t)_verts.size(), (ssize_t)indices.size()}; - _polygonInfo = SpritePolygonCache::getInstance()->addSpritePolygonCache(filename, rect, _triangles); + TrianglesCommand::Triangles triangles = {&_verts[0], &indices[0], (ssize_t)_verts.size(), (ssize_t)indices.size()}; + _polygonInfo = SpritePolygonCache::getInstance()->addSpritePolygonCache(filename, rect, triangles); calculateUVandContentSize(); setAnchorPoint(Vec2(0.5,0.5)); #if CC_SPRITE_DEBUG_DRAW @@ -456,7 +461,7 @@ void SpritePolygon::debugDraw() pos->x = v->vertices.x; pos->y = v->vertices.y; } - _debugDrawNode->drawPoints(positions, (unsigned int)_polygonInfo->_triangles.vertCount, 8, Color4F{0.0,1.0,1.0,1.0}); + _debugDrawNode->drawPoints(positions, (unsigned int)_polygonInfo->_triangles.vertCount, 8, Color4F(0.0f, 1.0f, 1.0f, 1.0f)); //draw lines auto last = _polygonInfo->_triangles.indexCount/3; auto _indices = _polygonInfo->_triangles.indices;