Skip to content

Commit

Permalink
Merge remote-tracking branch 'carlomorgantinizynga/LabelStrokeWithCla…
Browse files Browse the repository at this point in the history
…ss' into develop-v2

Conflicts:
	cocos2d/CCMenuItem.h

Former-commit-id: 14230d0f293f802eab883073a6aa4022d7055713
  • Loading branch information
ricardoquesada committed Jun 13, 2013
2 parents fa41f32 + 3948ddd commit 591607d
Show file tree
Hide file tree
Showing 6 changed files with 481 additions and 189 deletions.
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ People/companies who were/are contributing code to cocos2d for iPhone (alphabeti
* Ben Trengrove (http://bentrengrove.com/)
Added patch to support iPhone5 support in FileUtils

* Carlo Morgantini (http://zynga.com)
Added support for shadows and stroke in LabelTTF

* CJ Hanson (myBuddyCJ) (http://www.hansoninteractive.com/):
Director: Fixed the initial flicker + correct size at startup
Director: onExitTransitionDidFinish when the director is ended and other "corner" cases.
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version 2.1-final - XX-Jun-2013
. [NEW] EaseActions: Added CCEasePolynomialIn,Out,InOut
. [NEW] LabelTTF: Added support for Shadow and stroke
. [FIX] Actions: TargetedAction # startWithTarget uses correct arguments (issue #1488)
. [FIX] All: Compiles and runs on iOS7
. [3RD] SpiderMonkey: Updated to v21.0
Expand Down
6 changes: 6 additions & 0 deletions cocos2d/CCLabelTTF.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@
/** init the label with string and text definition*/
- (id) initWithString:(NSString *) string fontDefinition:(ccFontDefinition)definition;

/** get and set the font definition */
- (ccFontDefinition) getFontDefinition;

/** get and set the font definition */
- (void) setFontDefinition: (ccFontDefinition) fontDef;




Expand Down
49 changes: 48 additions & 1 deletion cocos2d/CCLabelTTF.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ @implementation CCLabelTTF
// -
+ (id) labelWithString:(NSString*)string fontDefinition:(ccFontDefinition)definition
{
return [[self alloc] initWithString:string fontDefinition:definition];
return [[[self alloc] initWithString:string fontDefinition:definition] autorelease];
}

// -
Expand Down Expand Up @@ -553,4 +553,51 @@ - (ccFontDefinition) prepareFontDefinitionAndAdjustForResolution:(Boolean) resAd
return texDef;
}

- (ccFontDefinition) getFontDefinition
{
return [self prepareFontDefinitionAndAdjustForResolution:false];
}

- (void) setFontDefinition: (ccFontDefinition) fontDef
{
if(_fontName)
{
[_fontName release];
}

_dimensions = fontDef.m_dimensions;
_hAlignment = fontDef.m_alignment;
_vAlignment = fontDef.m_vertAlignment;
_fontName = [fontDef.m_fontName copy];
_fontSize = fontDef.m_fontSize;
_lineBreakMode = fontDef.m_lineBreakMode;

// take care of shadow
if (fontDef.m_shadow.m_shadowEnabled)
{
[self enableShadowWithOffset:fontDef.m_shadow.m_shadowOffset opacity:fontDef.m_shadow.m_shadowOpacity blur:fontDef.m_shadow.m_shadowBlur updateImage: false];
}
else
{
[self disableShadowAndUpdateImage:false];
}

// take care of stroke
if (fontDef.m_stroke.m_strokeEnabled)
{
[self enableStrokeWithColor:fontDef.m_stroke.m_strokeColor size:fontDef.m_stroke.m_strokeSize updateImage:false];
}
else
{
[self disableStrokeAndUpdateImage:false];
}


[self setFontFillColor: fontDef.m_fontFillColor updateImage:false];


// actually update the texture
[self updateTexture];
}

@end
Loading

0 comments on commit 591607d

Please sign in to comment.