Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To create a stroke:</p> <pre><code>-(CCRenderTexture*) createStroke: (CCLabelTTF*) label size:(float)size color:(ccColor3B)cor { CCRenderTexture* rt = [CCRenderTexture renderTextureWithWidth:label.texture.contentSize.width+size*2 height:label.texture.contentSize.height+size*2]; CGPoint originalPos = [label position]; ccColor3B originalColor = [label color]; BOOL originalVisibility = [label visible]; [label setColor:cor]; [label setVisible:YES]; ccBlendFunc originalBlend = [label blendFunc]; [label setBlendFunc:(ccBlendFunc) { GL_SRC_ALPHA, GL_ONE }]; CGPoint bottomLeft = ccp(label.texture.contentSize.width * label.anchorPoint.x + size, label.texture.contentSize.height * label.anchorPoint.y + size); //CGPoint positionOffset = ccp(label.texture.contentSize.width * label.anchorPoint.x - label.texture.contentSize.width/2,label.texture.contentSize.height * label.anchorPoint.y - label.texture.contentSize.height/2); //use this for adding stoke to its self... CGPoint positionOffset= ccp(-label.contentSize.width/2,-label.contentSize.height/2); CGPoint position = ccpSub(originalPos, positionOffset); [rt begin]; for (int i=0; i&lt;360; i+=60) // you should optimize that for your needs { [label setPosition:ccp(bottomLeft.x + sin(CC_DEGREES_TO_RADIANS(i))*size, bottomLeft.y + cos(CC_DEGREES_TO_RADIANS(i))*size)]; [label visit]; } [rt end]; [[[rt sprite] texture] setAntiAliasTexParameters];//THIS [label setPosition:originalPos]; [label setColor:originalColor]; [label setBlendFunc:originalBlend]; [label setVisible:originalVisibility]; [rt setPosition:position]; return rt; } </code></pre> <p>Usage:</p> <pre><code>CCRenderTexture* myStroke = [self createStroke:myCCLabelTTF size:myStrokeSize color:ccYELLOW]; [myCCLabelTTF addChild:myStroke z:-1 tag:kTagStroke]; </code></pre> <p>And to increase smoothness, modify the following function to fit your needs (decrease the +60 increment to perhaps +30). Just note that the more iterations, the more more time spent rendering, which will negatively affect performance:</p> <pre><code>for (int i=0; i&lt;360; i+=60) // you should optimize that for your needs { [label setPosition:ccp(bottomLeft.x + sin(CC_DEGREES_TO_RADIANS(i))*size, bottomLeft.y + cos(CC_DEGREES_TO_RADIANS(i))*size)]; [label visit]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload