经调试发现问题出现在JNI层,解决方案:修改cocos2dx\platform\android下的CCImage.cpp文件
修改getBitmapFromJavaShadowStroke()方法中的
if (! JniHelper::getStaticMethodInfo(methodInfo, "org/cocos2dx/lib/Cocos2dxBitmap", "createTextBitmapShadowStroke",
"(Ljava/lang/String;Ljava/lang/String;IFFFIIIZFFFZFFFF)V"))
改为
if (! JniHelper::getStaticMethodInfo(methodInfo, "org/cocos2dx/lib/Cocos2dxBitmap", "createTextBitmapShadowStroke",
"([BLjava/lang/String;IFFFIIIZFFFZFFFF)V") )
把jstring jstrText = methodInfo.env->NewStringUTF(text);改成jbyteArray byteArray = methodInfo.env->NewByteArray(strlen(text));
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);
methodInfo.env->DeleteLocalRef(jstrText);
改成
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, byteArray,jstrFont, (int)fontSize, textTintR, textTintG, textTintB, eAlignMask, nWidth, nHeight, shadow, shadowDeltaX, -shadowDeltaY, shadowBlur, stroke, strokeColorR, strokeColorG, strokeColorB, strokeSize);
methodInfo.env->DeleteLocalRef(byteArray);
修改cocos2dx\platform\android\java\src\org\cocos2dx\lib下的Cocos2dxBitmap.java文件
public static void createTextBitmap方法中的第一个参数String pString改为final byte[] pString;
public static void createTextBitmapShadowStroke方法中的第一个参数String pString改为final byte[] pStringArr;
public static void createTextBitmapShadowStroke方法中pString = Cocos2dxBitmap.refactorString(pString);上一行添加String pString= new String(pStringArr);
结束。
这样,一些特殊符号,emoji表情什么的就可以正常显示啦。