From d26fa847d8e94e5d8736be261cc44a83d7364701 Mon Sep 17 00:00:00 2001 From: Jaroslaw Lewandowski Date: Tue, 2 Jul 2013 22:45:07 +0100 Subject: [PATCH] - Fixing shadows for text with stroke in iOS - Improved text shadows in Android (they look the same as in iOS) --- .../android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java | 2 +- cocos2dx/platform/ios/CCImage.mm | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java index fcd4598cde..2a0a915a02 100644 --- a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java @@ -128,7 +128,7 @@ public class Cocos2dxBitmap { if ( shadow ) { - int shadowColor = 0xff7d7d7d; + int shadowColor = 0x54000000; paint.setShadowLayer(shadowBlur, shadowDX, shadowDY, shadowColor); bitmapPaddingX = Math.abs(shadowDX); diff --git a/cocos2dx/platform/ios/CCImage.mm b/cocos2dx/platform/ios/CCImage.mm index cdd3a8a2c4..6c5f7e0a8c 100644 --- a/cocos2dx/platform/ios/CCImage.mm +++ b/cocos2dx/platform/ios/CCImage.mm @@ -365,10 +365,14 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig textOrigingY = startH - shadowStrokePaddingY; } + CGRect rect = CGRectMake(textOriginX, textOrigingY, textWidth, textHeight); + CGContextBeginTransparencyLayerWithRect(context, rect, NULL); // actually draw the text in the context // XXX: ios7 casting - [str drawInRect:CGRectMake(textOriginX, textOrigingY, textWidth, textHeight) withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)align]; + [str drawInRect: rect withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)align]; + + CGContextEndTransparencyLayer(context); // pop the context UIGraphicsPopContext();