本文整理汇总了C++中CCString::autorelease方法的典型用法代码示例。如果您正苦于以下问题:C++ CCString::autorelease方法的具体用法?C++ CCString::autorelease怎么用?C++ CCString::autorelease使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCString
的用法示例。
在下文中一共展示了CCString::autorelease方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fullPathFromRelativePath
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
{
// if have set the zip file path,return the relative path of zip file
if (strlen(s_pszZipFilePath) != 0)
{
return getDiffResolutionPath(pszRelativePath);
}
// get the user data path and append relative path to it
if (strlen(s_pszResourcePath) == 0)
{
const char* pAppDataPath = CCApplication::sharedApplication().getAppDataPath();
strcpy(s_pszResourcePath, pAppDataPath);
}
CCString * pRet = new CCString();
pRet->autorelease();
if ((strlen(pszRelativePath) > 1 && pszRelativePath[1] == ':') ||
(strlen(pszRelativePath) > 0 && pszRelativePath[0] == '/'))
{
pRet->m_sString = pszRelativePath;
}
else
{
pRet->m_sString = s_pszResourcePath;
pRet->m_sString += pszRelativePath;
}
return getDiffResolutionPath(pRet->m_sString.c_str());
}
示例2: BSStringByAppending
const char* BSStringByAppending(const char *pStr, const char *pAppend) {
char buff[255] = {0};
sprintf(buff, "%s%s", pStr, pAppend);
CCString* str = new CCString(buff);
str->autorelease();
return str->getCString();
}
示例3: BSStringFromInteger
const char* BSStringFromInteger(int pVal) {
char buff[12] = {0};
sprintf(buff, "%i", pVal);
CCString* str = new CCString(buff);
str->autorelease();
return str->getCString();
}
示例4: init
bool DragLayer::init()
{
if (!CCLayerColor::init()) {
return false;
}
//循环生成tableView数据
CCString *str = NULL;
for (int i = 0; i < 40; i++) {
str = new CCString("cellBg.jpg");
m_data->addObject(str);
str->autorelease();
}
//添加tableView到主界面上
CCSprite* cellBg = CCSprite::create("cellBg.jpg");
m_cellSize = CCSizeMake(cellBg->getContentSize().width, cellBg->getContentSize().height);
SNSTableView *tableView = SNSTableView::create(CCRectMake(0, 20, m_cellSize.width * 2, m_cellSize.height * 4), TableViewTypeHorizontal);
tableView->setDelegate(this);
tableView->setDatasource(this);
tableView->setPageEnable(true);
this->addChild(tableView);
//添加碰撞块
m_destinationLayer = CCLayerColor::create(ccc4(255, 255, 255, 255));
m_destinationLayer->setContentSize(CCSizeMake(93, 130));
m_destinationLayer->setPosition(ccp(360, 200));
m_destinationLayer->setAnchorPoint(ccp(0.5f, 0.5f));
this->addChild(m_destinationLayer);
this->setTouchEnabled(true);
return true;
}
示例5: fullPathFromRelativePath
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
{
IwAssert(GAME, pszRelativePath);
CCString * pRet = new CCString();
pRet->autorelease();
if ((strlen(pszRelativePath) > 1 && pszRelativePath[1] == ':'))
{
pRet->m_sString = pszRelativePath;
}
else if (strlen(pszRelativePath) > 0 && pszRelativePath[0] == '/')
{
char szDriver[3] = {s_pszResourcePath[0], s_pszResourcePath[1], 0};
pRet->m_sString = szDriver;
pRet->m_sString += pszRelativePath;
}
else
{
pRet->m_sString = s_pszResourcePath;
pRet->m_sString += pszRelativePath;
}
return pRet->m_sString.c_str();
}
示例6: CCString
const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile) {
std::string relativeFile = pszRelativeFile;
CCString *pRet = new CCString();
pRet->autorelease();
pRet->m_sString = relativeFile.substr(0, relativeFile.rfind('/')+1);
pRet->m_sString += pszFilename;
return pRet->m_sString.c_str();
}
示例7: CCString
const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)
{
_CheckPath();
// std::string relativeFile = fullPathFromRelativePath(pszRelativeFile);
std::string relativeFile = pszRelativeFile;
CCString *pRet = new CCString();
pRet->autorelease();
pRet->m_sString = relativeFile.substr(0, relativeFile.find_last_of("/\\") + 1);
pRet->m_sString += pszFilename;
return pRet->m_sString.c_str();
}
示例8: description
const char* CCBMFontConfiguration::description(void)
{
char* pBuf = new char[100];
sprintf(pBuf, "<CCBMFontConfiguration = %08X | Glphys:%d Kernings:%d | Image = %s>", this,
HASH_COUNT(m_pFontDefDictionary),
HASH_COUNT(m_pKerningDictionary),
m_sAtlasName.c_str());
CCString* pRet = new CCString(pBuf);
pRet->autorelease();
CC_SAFE_DELETE_ARRAY(pBuf);
return pRet->m_sString.c_str();
}
示例9: fullPathFromRelativePath
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType)
{
_CheckPath();
CCString * pRet = new CCString();
pRet->autorelease();
if ((strlen(pszRelativePath) > 1 && pszRelativePath[1] == ':'))
{
// path start with "x:", is absolute path
pRet->m_sString = pszRelativePath;
}
else if (strlen(pszRelativePath) > 0
&& ('/' == pszRelativePath[0] || '\\' == pszRelativePath[0]))
{
// path start with '/' or '\', is absolute path without driver name
char szDriver[3] = {s_pszResourcePath[0], s_pszResourcePath[1], 0};
pRet->m_sString = szDriver;
pRet->m_sString += pszRelativePath;
}
else
{
pRet->m_sString = s_pszResourcePath;
pRet->m_sString += pszRelativePath;
}
//#if (CC_IS_RETINA_DISPLAY_SUPPORTED)
// if (CC_CONTENT_SCALE_FACTOR() != 1.0f)
// {
// std::string hiRes = pRet->m_sString.c_str();
// std::string::size_type pos = hiRes.find_last_of("/\\");
// std::string::size_type dotPos = hiRes.find_last_of(".");
//
// if (std::string::npos != dotPos && dotPos > pos)
// {
// hiRes.insert(dotPos, CC_RETINA_DISPLAY_FILENAME_SUFFIX);
// }
// else
// {
// hiRes.append(CC_RETINA_DISPLAY_FILENAME_SUFFIX);
// }
// DWORD attrib = GetFileAttributesA(hiRes.c_str());
//
// if (attrib != INVALID_FILE_ATTRIBUTES && ! (FILE_ATTRIBUTE_DIRECTORY & attrib))
// {
// pRet->m_sString.swap(hiRes);
// }
// }
//#endif
if (pResolutionType)
{
*pResolutionType = kCCResolutioniPhone;
}
return pRet->m_sString.c_str();
}
示例10: getLocalLanguage
const char* getLocalLanguage()
{
JniMethodInfo minfo;
CCAssert(JniHelper::getStaticMethodInfo(minfo, "org/cocos2dx/lib/Cocos2dxHelper", "getCurrentLanguage", "()Ljava/lang/String;"), "Function doesn't exist");
jstring str = (jstring)minfo.env->CallStaticObjectMethod(minfo.classID, minfo.methodID);
minfo.env->DeleteLocalRef(minfo.classID);
CCString *ret = new CCString(JniHelper::jstring2string(str).c_str());
ret->autorelease();
minfo.env->DeleteLocalRef(str);
return ret->m_sString.c_str();
}
示例11: getDiffResolutionPath
const char* getDiffResolutionPath(const char *pszPath)
{
CCString *pRet = new CCString(pszPath);
pRet->autorelease();
do
{
TApplication* pApp = TApplication::GetCurrentApplication();
CC_BREAK_IF(!pApp);
// get the Resolution
int nScreenWidth = pApp->GetScreenWidth();
int nScreenHeight = pApp->GetScreenHeight();
// it's default resolution, do nothing
CC_BREAK_IF(nScreenWidth == 320 && nScreenHeight == 480);
if (nScreenWidth == 480 && nScreenHeight == 800)
{
// it's WVGA
CC_BREAK_IF(pRet->m_sString.find("@WVGA") != -1);
std::string filePathWithoutExtension = pszPath;
std::string extension = "";
std::string filePath = pszPath;
int nExPos = filePath.find_last_of(".");
if (nExPos != -1)
{
filePathWithoutExtension = filePath.substr(0, nExPos);
extension = filePath.substr(nExPos);
}
// new path, add "@WVGA" before the extension
pRet->m_sString = filePathWithoutExtension + "@WVGA" + extension;
// not find the resource of new path,use the original path
if (! isResourceExist(pRet->m_sString.c_str()))
{
pRet->m_sString = filePath;
}
}
else
{
// not support resolution
CCAssert(0, "it's not supportted resolution.");
}
} while (0);
return pRet->m_sString.c_str();
}
示例12: getCurrentLanguageJNI
const char* getCurrentLanguageJNI() {
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getCurrentLanguage", "()Ljava/lang/String;")) {
jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
t.env->DeleteLocalRef(t.classID);
CCString *ret = new CCString(JniHelper::jstring2string(str).c_str());
ret->autorelease();
t.env->DeleteLocalRef(str);
return ret->m_sString.c_str();
}
return 0;
}
示例13: fullPathFromRelativePath
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
{
// It works like this: if the relative path already includes the resource path
// it will be returned as it is
const std::string relPath = pszRelativePath;
if (relPath.find(s_strResourcePath) == std::string::npos) {
CCString *pRet = new CCString();
pRet->autorelease();
pRet->m_sString = s_strResourcePath + pszRelativePath;
return pRet->m_sString.c_str();
}
else {
return pszRelativePath;
}
}
示例14: handleDialogCompleted
void CCGreeRequestDialog::handleDialogCompleted(int count, const char** users){
CCGreeRequestDialogDelegate *delegate = CCGreePlatform::getRequestDialogDelegate();
if(delegate != NULL){
CCArray *userStringArray = new CCArray();
if(users != NULL){
for(int i = 0; i < count; i++){
CCString *str = new CCString(users[i]);
str->autorelease();
userStringArray->addObject(str);
}
}
delegate->requestDialogCompleted(this, userStringArray);
delegate->requestDialogClosed(this);
}
}
示例15: getCurrentLanguageJNI
//////////////////////////////////////////////////////////////////////////
// handle get current language
//////////////////////////////////////////////////////////////////////////
const char* getCurrentLanguageJNI()
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t
, "org/cocos2dx/lib/Cocos2dxActivity"
, "getCurrentLanguage"
, "()Ljava/lang/String;"))
{
jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
t.env->DeleteLocalRef(t.classID);
CCString *ret = new CCString(JniHelper::jstring2string(str).c_str());
ret->autorelease();
t.env->DeleteLocalRef(str);
LOGD("language name %s", ret.c_str());
return ret->m_sString.c_str();
}
return 0;
}