diff --git a/cocos2d/core/sprites/CCScale9Sprite.js b/cocos2d/core/sprites/CCScale9Sprite.js index ab8c6029f5..0f1c2483be 100644 --- a/cocos2d/core/sprites/CCScale9Sprite.js +++ b/cocos2d/core/sprites/CCScale9Sprite.js @@ -375,99 +375,7 @@ cc.TiledQuadGenerator = { } }; //todo -cc.FilledQuadGenerator = { - _rebuildQuads_base : function (spriteFrame, contentSize, colorOpacity) { - var quads = []; - //build vertices - var vertices = this._calculateVertices(spriteFrame, contentSize); - - //build uvs - var uvs = this._calculateUVs(spriteFrame); - - //build quads - var quad; - quad = new cc.V3F_C4B_T2F_Quad(); - - quad._bl.colors = colorOpacity; - quad._br.colors = colorOpacity; - quad._tl.colors = colorOpacity; - quad._tr.colors = colorOpacity; - - quad._bl.vertices = new cc.Vertex3F(vertices[0].x, vertices[0].y, 0); - quad._br.vertices = new cc.Vertex3F(vertices[1].x, vertices[0].y, 0); - quad._tl.vertices = new cc.Vertex3F(vertices[0].x, vertices[1].y, 0); - quad._tr.vertices = new cc.Vertex3F(vertices[1].x, vertices[1].y, 0); - - if (!spriteFrame._rotated) { - quad._bl.texCoords = new cc.Tex2F(uvs[0].x, uvs[0].y); - quad._br.texCoords = new cc.Tex2F(uvs[1].x, uvs[0].y); - quad._tl.texCoords = new cc.Tex2F(uvs[0].x, uvs[1].y); - quad._tr.texCoords = new cc.Tex2F(uvs[1].x, uvs[1].y); - } else { - quad._bl.texCoords = new cc.Tex2F(uvs[0].x, uvs[1].y); - quad._br.texCoords = new cc.Tex2F(uvs[0].x, uvs[0].y); - quad._tl.texCoords = new cc.Tex2F(uvs[1].x, uvs[1].y); - quad._tr.texCoords = new cc.Tex2F(uvs[1].x, uvs[0].y); - } - quads.push(quad); - return quads; - }, - - _calculateVertices : function (spriteFrame, contentSize) { - - var x0,x3; - var y0,y3; - x0 = 0; - x3 = contentSize.width; - - y0 = 0; - y3 = contentSize.height; - - //apply contentscale factor - x0 = x0 / cc.contentScaleFactor(); - x3 = x3 / cc.contentScaleFactor(); - y0 = y0 / cc.contentScaleFactor(); - y3 = y3 / cc.contentScaleFactor(); - - var vertices = []; - vertices.push(cc.p(x0, y0)); - vertices.push(cc.p(x3, y3)); - - return vertices; - }, - - _calculateUVs : function (spriteFrame) { - var atlasWidth = spriteFrame._texture.getPixelWidth(); - var atlasHeight = spriteFrame._texture.getPixelHeight(); - - var textureRect = cc.rectPointsToPixels(spriteFrame.getRect()); - - //uv computation should take spritesheet into account. - var u0, u3; - var v0, v3; - - if (spriteFrame._rotated) { - u0 = textureRect.x / atlasWidth; - u3 = (textureRect.x + textureRect.height) / atlasWidth; - - v0 = textureRect.y / atlasHeight; - v3 = (textureRect.y + textureRect.width) / atlasHeight; - } - else { - u0 = textureRect.x / atlasWidth; - u3 = (textureRect.x + textureRect.width) / atlasWidth; - - v0 = textureRect.y / atlasHeight; - v3 = (textureRect.y + textureRect.height) / atlasHeight; - } - - var uvCoordinates = []; - uvCoordinates.push(cc.p(u0, v3)); - uvCoordinates.push(cc.p(u3, v0)); - - return uvCoordinates; - } -}; +cc.FilledQuadGenerator = cc.SimpleQuadGenerator; cc.Scale9Sprite = _ccsg.Node.extend({ //resource data, could be async loaded. @@ -737,6 +645,7 @@ cc.Scale9Sprite = _ccsg.Node.extend({ } else if (this._renderingType === cc.Scale9Sprite.RenderingType.TILED) { this._quads = cc.TiledQuadGenerator._rebuildQuads_base(this._spriteFrame, this.getContentSize(), color); } else if (this._renderingType === cc.Scale9Sprite.RenderingType.FILLED) { + cc.error("Filled sprite not implemented."); this._quads = cc.FilledQuadGenerator._rebuildQuads_base(this._spriteFrame, this.getContentSize(), color); } else { this._quads = [];