mirror of https://github.com/axmolengine/axmol.git
Now opacity option for shadow in CCLabelTTF works.
This commit is contained in:
parent
502896b3a6
commit
f1023232db
|
@ -72,7 +72,7 @@ public:
|
|||
float shadowDeltaX = 0.0,
|
||||
float shadowDeltaY = 0.0,
|
||||
float shadowBlur = 0.0,
|
||||
float shadowIntensity = 0.0,
|
||||
float shadowOpacity = 0.0,
|
||||
bool stroke = false,
|
||||
float strokeColorR = 0.0,
|
||||
float strokeColorG = 0.0,
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
{
|
||||
JniMethodInfo methodInfo;
|
||||
if (! JniHelper::getStaticMethodInfo(methodInfo, "org/cocos2dx/lib/Cocos2dxBitmap", "createTextBitmapShadowStroke",
|
||||
"(Ljava/lang/String;Ljava/lang/String;IFFFIIIZFFFZFFFF)V"))
|
||||
"(Ljava/lang/String;Ljava/lang/String;IFFFIIIZFFFFZFFFF)V"))
|
||||
{
|
||||
CCLOG("%s %d: error to get methodInfo", __FILE__, __LINE__);
|
||||
return false;
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
jstring jstrFont = methodInfo.env->NewStringUTF(fullPathOrFontName.c_str());
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, jstrText,
|
||||
jstrFont, (int)fontSize, textTintR, textTintG, textTintB, eAlignMask, nWidth, nHeight, shadow, shadowDeltaX, -shadowDeltaY, shadowBlur, stroke, strokeColorR, strokeColorG, strokeColorB, strokeSize);
|
||||
jstrFont, (int)fontSize, textTintR, textTintG, textTintB, eAlignMask, nWidth, nHeight, shadow, shadowDeltaX, -shadowDeltaY, shadowBlur, shadowOpacity, stroke, strokeColorR, strokeColorG, strokeColorB, strokeSize);
|
||||
|
||||
methodInfo.env->DeleteLocalRef(jstrText);
|
||||
methodInfo.env->DeleteLocalRef(jstrFont);
|
||||
|
|
|
@ -96,7 +96,7 @@ public class Cocos2dxBitmap {
|
|||
//
|
||||
createTextBitmapShadowStroke( pString, pFontName, pFontSize, 1.0f, 1.0f, 1.0f, // text font and color
|
||||
pAlignment, pWidth, pHeight, // alignment and size
|
||||
false, 0.0f, 0.0f, 0.0f, // no shadow
|
||||
false, 0.0f, 0.0f, 0.0f, 0.0f, // no shadow
|
||||
false, 1.0f, 1.0f, 1.0f, 1.0f); // no stroke
|
||||
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class Cocos2dxBitmap {
|
|||
public static void createTextBitmapShadowStroke(String pString, final String pFontName, final int pFontSize,
|
||||
final float fontTintR, final float fontTintG, final float fontTintB,
|
||||
final int pAlignment, final int pWidth, final int pHeight, final boolean shadow,
|
||||
final float shadowDX, final float shadowDY, final float shadowBlur, final boolean stroke,
|
||||
final float shadowDX, final float shadowDY, final float shadowBlur, final float shadowOpacity, final boolean stroke,
|
||||
final float strokeR, final float strokeG, final float strokeB, final float strokeSize) {
|
||||
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class Cocos2dxBitmap {
|
|||
|
||||
if ( shadow ) {
|
||||
|
||||
int shadowColor = 0x54000000;
|
||||
int shadowColor = ((int)(255 * shadowOpacity) & 0xff) << 24;
|
||||
paint.setShadowLayer(shadowBlur, shadowDX, shadowDY, shadowColor);
|
||||
|
||||
bitmapPaddingX = Math.abs(shadowDX);
|
||||
|
|
|
@ -279,12 +279,10 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig
|
|||
8,
|
||||
(int)(dim.width) * 4,
|
||||
colorSpace,
|
||||
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
|
||||
|
||||
CGColorSpaceRelease(colorSpace);
|
||||
|
||||
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
|
||||
if (!context)
|
||||
{
|
||||
CGColorSpaceRelease(colorSpace);
|
||||
delete[] data;
|
||||
break;
|
||||
}
|
||||
|
@ -319,9 +317,15 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig
|
|||
CGSize offset;
|
||||
offset.height = pInfo->shadowOffset.height;
|
||||
offset.width = pInfo->shadowOffset.width;
|
||||
CGContextSetShadow(context, offset, pInfo->shadowBlur);
|
||||
CGFloat shadowColorValues[] = {0, 0, 0, pInfo->shadowOpacity};
|
||||
CGColorRef shadowColor = CGColorCreate (colorSpace, shadowColorValues);
|
||||
|
||||
CGContextSetShadowWithColor(context, offset, pInfo->shadowBlur, shadowColor);
|
||||
|
||||
CGColorRelease (shadowColor);
|
||||
}
|
||||
|
||||
CGColorSpaceRelease(colorSpace);
|
||||
|
||||
|
||||
// normal fonts
|
||||
|
|
Loading…
Reference in New Issue