Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3_7_test

This commit is contained in:
samuele3hu 2015-06-23 20:03:14 +08:00
commit 5c5f3dcc79
49 changed files with 458 additions and 358 deletions

View File

@ -152,12 +152,8 @@ void Camera::lookAt(const Vec3& lookAtPos, const Vec3& up)
Quaternion quaternion;
Quaternion::createFromRotationMatrix(rotation,&quaternion);
float rotx = atan2f(2 * (quaternion.w * quaternion.x + quaternion.y * quaternion.z), 1 - 2 * (quaternion.x * quaternion.x + quaternion.y * quaternion.y));
float roty = asin(clampf(2 * (quaternion.w * quaternion.y - quaternion.z * quaternion.x) , -1.0f , 1.0f));
float rotz = -atan2(2 * (quaternion.w * quaternion.z + quaternion.x * quaternion.y) , 1 - 2 * (quaternion.y * quaternion.y + quaternion.z * quaternion.z));
setRotation3D(Vec3(CC_RADIANS_TO_DEGREES(rotx),CC_RADIANS_TO_DEGREES(roty),CC_RADIANS_TO_DEGREES(rotz)));
quaternion.normalize();
setRotationQuat(quaternion);
}
const Mat4& Camera::getViewProjectionMatrix() const

View File

@ -690,7 +690,7 @@ void Label::updateQuads()
}
if (_lettersInfo[ctr].position.y - letterDef.height < 0.f)
{
_reusedRect.size.height = _lettersInfo[ctr].position.y;
_reusedRect.size.height = _lettersInfo[ctr].position.y < 0.f ? 0.f : _lettersInfo[ctr].position.y;
}
_reusedLetter->setTextureRect(_reusedRect,false,_reusedRect.size);

View File

@ -61,11 +61,13 @@ void Audio::Initialize()
void Audio::CreateResources()
{
try
do
{
ThrowIfFailed(
XAudio2Create(&m_musicEngine)
);
if (FAILED(XAudio2Create(&m_musicEngine)))
{
m_engineExperiencedCriticalError = true;
break;
}
#if defined(_DEBUG)
XAUDIO2_DEBUG_CONFIGURATION debugConfig = {0};
@ -83,31 +85,33 @@ void Audio::CreateResources()
// decode the data then we feed it through the XAudio2 pipeline as a separate Mastering Voice, so that we can tag it
// as Game Media.
// We default the mastering voice to 2 channels to simplify the reverb logic.
ThrowIfFailed(
m_musicEngine->CreateMasteringVoice(&m_musicMasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameMedia)
);
if(FAILED(m_musicEngine->CreateMasteringVoice(&m_musicMasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameMedia)))
{
m_engineExperiencedCriticalError = true;
break;
}
// Create a separate engine and mastering voice for sound effects in the sample
// Games will use many voices in a complex graph for audio, mixing all effects down to a
// single mastering voice.
// We are creating an entirely new engine instance and mastering voice in order to tag
// our sound effects with the audio category AudioCategory_GameEffects.
ThrowIfFailed(
XAudio2Create(&m_soundEffectEngine)
);
if(FAILED(XAudio2Create(&m_soundEffectEngine)))
{
m_engineExperiencedCriticalError = true;
break;
}
m_soundEffectEngineCallback.Initialize(this);
m_soundEffectEngine->RegisterForCallbacks(&m_soundEffectEngineCallback);
// We default the mastering voice to 2 channels to simplify the reverb logic.
ThrowIfFailed(
m_soundEffectEngine->CreateMasteringVoice(&m_soundEffectMasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameEffects)
);
}
catch (...)
{
m_engineExperiencedCriticalError = true;
}
if(FAILED(m_soundEffectEngine->CreateMasteringVoice(&m_soundEffectMasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameEffects)))
{
m_engineExperiencedCriticalError = true;
break;
}
} while (false);
}
unsigned int Audio::Hash(const char *key)
@ -309,9 +313,10 @@ void Audio::PlaySoundEffect(unsigned int sound)
StopSoundEffect(sound);
ThrowIfFailed(
m_soundEffects[sound].m_soundEffectSourceVoice->SubmitSourceBuffer(&m_soundEffects[sound].m_audioBuffer)
);
if (FAILED(m_soundEffects[sound].m_soundEffectSourceVoice->SubmitSourceBuffer(&m_soundEffects[sound].m_audioBuffer)))
{
m_engineExperiencedCriticalError = true;
}
if (m_engineExperiencedCriticalError) {
// If there's an error, then we'll recreate the engine on the next render pass
@ -560,10 +565,11 @@ void Audio::PreloadSoundEffect(const char* pszFilePath, bool isMusic)
sends.SendCount = 1;
sends.pSends = descriptors;
ThrowIfFailed(
m_musicEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice,
&wfx, 0, 1.0f, &m_voiceContext, &sends)
);
if (FAILED(m_musicEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice,
&wfx, 0, 1.0f, &m_voiceContext, &sends)))
{
m_engineExperiencedCriticalError = true;
}
//fix bug: set a initial volume
m_soundEffects[sound].m_soundEffectSourceVoice->SetVolume(m_backgroundMusicVolume);
} else
@ -575,10 +581,11 @@ void Audio::PreloadSoundEffect(const char* pszFilePath, bool isMusic)
sends.SendCount = 1;
sends.pSends = descriptors;
ThrowIfFailed(
m_soundEffectEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice,
&wfx, 0, 1.0f, &m_voiceContext, &sends, nullptr)
);
if(FAILED(m_soundEffectEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice,
&wfx, 0, 1.0f, &m_voiceContext, &sends, nullptr)))
{
m_engineExperiencedCriticalError = true;
}
//fix bug: set a initial volume
m_soundEffects[sound].m_soundEffectSourceVoice->SetVolume(m_soundEffctVolume);
}

View File

@ -311,6 +311,7 @@ void AudioPlayer::setVolume(float volume)
bool AudioPlayer::play2d(AudioCache* cache)
{
bool ret = false;
HRESULT hr = S_OK;
if (cache != nullptr)
{
@ -323,12 +324,14 @@ bool AudioPlayer::play2d(AudioCache* cache)
XAUDIO2_VOICE_SENDS sends = { 0 };
sends.SendCount = 1;
sends.pSends = descriptors;
ThrowIfFailed(_xaEngine->CreateSourceVoice(&_xaSourceVoice, &cache->_audInfo._wfx, 0, 1.0, this, &sends));
hr = _xaEngine->CreateSourceVoice(&_xaSourceVoice, &cache->_audInfo._wfx, 0, 1.0, this, &sends);
}
_isStreaming = _cache->isStreamingSource();
_duration = getDuration();
ret = _play();
if (SUCCEEDED(hr)) {
_isStreaming = _cache->isStreamingSource();
_duration = getDuration();
ret = _play();
}
}
return ret;
@ -336,20 +339,26 @@ bool AudioPlayer::play2d(AudioCache* cache)
void AudioPlayer::init()
{
memset(&_xaBuffer, 0, sizeof(_xaBuffer));
ThrowIfFailed(XAudio2Create(_xaEngine.ReleaseAndGetAddressOf()));
do {
memset(&_xaBuffer, 0, sizeof(_xaBuffer));
if (FAILED(XAudio2Create(_xaEngine.ReleaseAndGetAddressOf()))) {
break;
}
#if defined(_DEBUG)
XAUDIO2_DEBUG_CONFIGURATION debugConfig = { 0 };
debugConfig.BreakMask = XAUDIO2_LOG_ERRORS;
debugConfig.TraceMask = XAUDIO2_LOG_ERRORS;
_xaEngine->SetDebugConfiguration(&debugConfig);
XAUDIO2_DEBUG_CONFIGURATION debugConfig = { 0 };
debugConfig.BreakMask = XAUDIO2_LOG_ERRORS;
debugConfig.TraceMask = XAUDIO2_LOG_ERRORS;
_xaEngine->SetDebugConfiguration(&debugConfig);
#endif
_xaEngine->RegisterForCallbacks(this);
ThrowIfFailed(_xaEngine->CreateMasteringVoice(&_xaMasterVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameMedia));
_ready = true;
_state = AudioPlayerState::READY;
_xaEngine->RegisterForCallbacks(this);
if (FAILED(_xaEngine->CreateMasteringVoice(&_xaMasterVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameMedia))) {
break;
}
_ready = true;
_state = AudioPlayerState::READY;
} while (false);
}
void AudioPlayer::free()

View File

@ -1007,6 +1007,9 @@ void Director::restartDirector()
{
reset();
// RenderState need to be reinitialized
RenderState::initialize();
// Texture cache need to be reinitialized
initTextureCache();

View File

@ -54,23 +54,23 @@ ComRender::~ComRender(void)
void ComRender::onEnter()
{
if (_owner != nullptr)
if (_owner != nullptr && _render->getParent() == nullptr)
{
_owner->addChild(_render);
_owner->addChild(_render);
}
}
void ComRender::onExit()
{
if (_owner != nullptr)
if (_owner != nullptr && _render->getParent() == nullptr)
{
_owner->removeChild(_render, true);
_owner->removeChild(_render, true);
}
}
void ComRender::onAdd()
{
if (_owner != nullptr)
if (_owner != nullptr && _render->getParent() == nullptr)
{
_owner->addChild(_render);
}
@ -78,7 +78,7 @@ void ComRender::onAdd()
void ComRender::onRemove()
{
if (_owner != nullptr)
if (_owner != nullptr && _render->getParent() == nullptr)
{
_owner->removeChild(_render, true);
}
@ -104,128 +104,129 @@ void ComRender::setNode(cocos2d::Node *node)
}
// TODO: This method is soooo big!! We should refactor it!
bool ComRender::serialize(void* r)
{
bool ret = false;
bool ret = false;
do
{
CC_BREAK_IF(r == nullptr);
SerData *serData = (SerData *)(r);
SerData *serData = (SerData *)(r);
const rapidjson::Value *v = serData->_rData;
stExpCocoNode *cocoNode = serData->_cocoNode;
stExpCocoNode *cocoNode = serData->_cocoNode;
CocoLoader *cocoLoader = serData->_cocoLoader;
const char *className = nullptr;
const char *comName = nullptr;
const char *file = nullptr;
const char *plist = nullptr;
std::string filePath;
std::string plistPath;
int resType = 0;
if (v != nullptr)
{
className = DICTOOL->getStringValue_json(*v, "classname");
CC_BREAK_IF(className == nullptr);
comName = DICTOOL->getStringValue_json(*v, "name");
const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData");
CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData));
file = DICTOOL->getStringValue_json(fileData, "path");
plist = DICTOOL->getStringValue_json(fileData, "plistFile");
CC_BREAK_IF(file == nullptr && plist == nullptr);
resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1);
}
else if(cocoNode != nullptr)
{
className = cocoNode[1].GetValue(cocoLoader);
CC_BREAK_IF(className == nullptr);
comName = cocoNode[2].GetValue(cocoLoader);
stExpCocoNode *pfileData = cocoNode[4].GetChildArray(cocoLoader);
CC_BREAK_IF(!pfileData);
file = pfileData[0].GetValue(cocoLoader);
plist = pfileData[1].GetValue(cocoLoader);
CC_BREAK_IF(file == nullptr && plist == nullptr);
resType = atoi(pfileData[2].GetValue(cocoLoader));
}
if (comName != nullptr)
{
setName(comName);
}
else
{
setName(className);
}
const char *className = nullptr;
const char *comName = nullptr;
const char *file = nullptr;
const char *plist = nullptr;
std::string filePath;
std::string plistPath;
int resType = 0;
if (v != nullptr)
{
className = DICTOOL->getStringValue_json(*v, "classname");
CC_BREAK_IF(className == nullptr);
comName = DICTOOL->getStringValue_json(*v, "name");
const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData");
CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData));
file = DICTOOL->getStringValue_json(fileData, "path");
plist = DICTOOL->getStringValue_json(fileData, "plistFile");
CC_BREAK_IF(file == nullptr && plist == nullptr);
resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1);
}
else if(cocoNode != nullptr)
{
className = cocoNode[1].GetValue(cocoLoader);
CC_BREAK_IF(className == nullptr);
comName = cocoNode[2].GetValue(cocoLoader);
stExpCocoNode *pfileData = cocoNode[4].GetChildArray(cocoLoader);
CC_BREAK_IF(!pfileData);
file = pfileData[0].GetValue(cocoLoader);
plist = pfileData[1].GetValue(cocoLoader);
CC_BREAK_IF(file == nullptr && plist == nullptr);
resType = atoi(pfileData[2].GetValue(cocoLoader));
}
if (comName != nullptr)
{
setName(comName);
}
else
{
setName(className);
}
if (file != nullptr)
{
filePath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(file));
}
if (plist != nullptr)
{
plistPath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(plist));
}
if (resType == 0)
{
if (strcmp(className, "CCSprite") == 0 && (filePath.find(".png") != filePath.npos || filePath.find(".pvr.ccz") != filePath.npos))
{
_render = CCSprite::create(filePath.c_str());
_render->retain();
if (file != nullptr)
{
filePath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(file));
}
if (plist != nullptr)
{
plistPath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(plist));
}
if (resType == 0)
{
if (strcmp(className, "CCSprite") == 0 && (filePath.find(".png") != filePath.npos || filePath.find(".pvr.ccz") != filePath.npos))
{
_render = Sprite::create(filePath.c_str());
_render->retain();
ret = true;
}
else if(strcmp(className, "CCTMXTiledMap") == 0 && filePath.find(".tmx") != filePath.npos)
{
_render = CCTMXTiledMap::create(filePath.c_str());
_render->retain();
}
else if(strcmp(className, "CCTMXTiledMap") == 0 && filePath.find(".tmx") != filePath.npos)
{
_render = TMXTiledMap::create(filePath.c_str());
_render->retain();
ret = true;
}
else if(strcmp(className, "CCParticleSystemQuad") == 0 && filePath.find(".plist") != filePath.npos)
{
_render = CCParticleSystemQuad::create(filePath.c_str());
_render->setPosition(0.0f, 0.0f);
_render->retain();
}
else if(strcmp(className, "CCParticleSystemQuad") == 0 && filePath.find(".plist") != filePath.npos)
{
_render = ParticleSystemQuad::create(filePath.c_str());
_render->setPosition(0.0f, 0.0f);
_render->retain();
ret = true;
}
else if(strcmp(className, "CCArmature") == 0)
{
std::string file_extension = filePath;
size_t pos = filePath.find_last_of('.');
if (pos != std::string::npos)
{
file_extension = filePath.substr(pos, filePath.length());
std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper);
}
if (file_extension == ".JSON" || file_extension == ".EXPORTJSON")
{
rapidjson::Document doc;
if(!readJson(filePath.c_str(), doc))
{
log("read json file[%s] error!\n", filePath.c_str());
continue;
}
const rapidjson::Value &subData = DICTOOL->getDictionaryFromArray_json(doc, "armature_data", 0);
const char *name = DICTOOL->getStringValue_json(subData, "name");
ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath.c_str());
Armature *pAr = Armature::create(name);
_render = pAr;
_render->retain();
const char *actionName = nullptr;
if (cocoNode != nullptr)
{
actionName = cocoNode[6].GetValue(cocoLoader);//DICTOOL->getStringValue_json(*v, "selectedactionname");
}
else
{
actionName = DICTOOL->getStringValue_json(*v, "selectedactionname");
}
if (actionName != nullptr && pAr->getAnimation() != nullptr)
{
pAr->getAnimation()->play(actionName);
}
}
else if(strcmp(className, "CCArmature") == 0)
{
std::string file_extension = filePath;
size_t pos = filePath.find_last_of('.');
if (pos != std::string::npos)
{
file_extension = filePath.substr(pos, filePath.length());
std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper);
}
if (file_extension == ".JSON" || file_extension == ".EXPORTJSON")
{
rapidjson::Document doc;
if(!readJson(filePath.c_str(), doc))
{
log("read json file[%s] error!\n", filePath.c_str());
continue;
}
const rapidjson::Value &subData = DICTOOL->getDictionaryFromArray_json(doc, "armature_data", 0);
const char *name = DICTOOL->getStringValue_json(subData, "name");
ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath.c_str());
Armature *pAr = Armature::create(name);
_render = pAr;
_render->retain();
const char *actionName = nullptr;
if (cocoNode != nullptr)
{
actionName = cocoNode[6].GetValue(cocoLoader);//DICTOOL->getStringValue_json(*v, "selectedactionname");
}
else
{
actionName = DICTOOL->getStringValue_json(*v, "selectedactionname");
}
if (actionName != nullptr && pAr->getAnimation() != nullptr)
{
pAr->getAnimation()->play(actionName);
}
ret = true;
}
else if (file_extension == ".CSB")
{
}
else if (file_extension == ".CSB")
{
std::string binaryFilePath = FileUtils::getInstance()->fullPathForFilename(filePath.c_str());
auto fileData = FileUtils::getInstance()->getDataFromFile(binaryFilePath);
auto fileDataBytes = fileData.getBytes();
@ -233,10 +234,10 @@ bool ComRender::serialize(void* r)
CocoLoader tCocoLoader;
if (tCocoLoader.ReadCocoBinBuff((char*)fileDataBytes))
{
stExpCocoNode *tpRootCocoNode = tCocoLoader.GetRootCocoNode();
rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader);
if (rapidjson::kObjectType == tType)
{
stExpCocoNode *tpRootCocoNode = tCocoLoader.GetRootCocoNode();
rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader);
if (rapidjson::kObjectType == tType)
{
int count = tpRootCocoNode->GetChildNum();
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader);
for (int i = 0; i < count; ++i)
@ -262,7 +263,7 @@ bool ComRender::serialize(void* r)
if (str1 != nullptr)
{
ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath.c_str());
Armature *pAr = CCArmature::create(str1);
Armature *pAr = Armature::create(str1);
_render = pAr;
_render->retain();
const char *actionName = nullptr;
@ -284,75 +285,75 @@ bool ComRender::serialize(void* r)
}
}
}
}
}
}
}
else
{
continue;
}
}
}
else
{
continue;
}
}
else if(strcmp(className, "GUIComponent") == 0)
{
std::string file_extension = filePath;
size_t pos = filePath.find_last_of('.');
if (pos != std::string::npos)
{
file_extension = filePath.substr(pos, filePath.length());
std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper);
}
if (file_extension == ".JSON" || file_extension == ".EXPORTJSON")
{
}
else if(strcmp(className, "GUIComponent") == 0)
{
std::string file_extension = filePath;
size_t pos = filePath.find_last_of('.');
if (pos != std::string::npos)
{
file_extension = filePath.substr(pos, filePath.length());
std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper);
}
if (file_extension == ".JSON" || file_extension == ".EXPORTJSON")
{
cocos2d::ui::Widget* widget = GUIReader::getInstance()->widgetFromJsonFile(filePath.c_str());
_render = widget;
_render->retain();
ret = true;
}
else if (file_extension == ".CSB")
{
}
else if (file_extension == ".CSB")
{
cocos2d::ui::Widget* widget = GUIReader::getInstance()->widgetFromBinaryFile(filePath.c_str());
_render = widget;
_render->retain();
ret = true;
}
}
else
{
CC_BREAK_IF(true);
}
}
else if (resType == 1)
{
if (strcmp(className, "CCSprite") == 0)
{
std::string strPngFile = plistPath;
std::string::size_type pos = strPngFile.find(".plist");
if (pos == strPngFile.npos)
{
continue;
}
strPngFile.replace(pos, strPngFile.length(), ".png");
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath.c_str(), strPngFile.c_str());
_render = CCSprite::createWithSpriteFrameName(filePath.c_str());
_render->retain();
}
}
else
{
CC_BREAK_IF(true);
}
}
else if (resType == 1)
{
if (strcmp(className, "CCSprite") == 0)
{
std::string strPngFile = plistPath;
std::string::size_type pos = strPngFile.find(".plist");
if (pos == strPngFile.npos)
{
continue;
}
strPngFile.replace(pos, strPngFile.length(), ".png");
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath.c_str(), strPngFile.c_str());
_render = Sprite::createWithSpriteFrameName(filePath.c_str());
_render->retain();
ret = true;
}
else
{
CC_BREAK_IF(true);
}
}
else
{
CC_BREAK_IF(true);
}
}
else
{
CC_BREAK_IF(true);
}
}
else
{
CC_BREAK_IF(true);
}
} while (0);
return ret;

View File

@ -1417,29 +1417,33 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(const rapidjson::Value& json, D
{
displayData = new (std::nothrow) SpriteDisplayData();
const char *name = DICTOOL->getStringValue_json(json, A_NAME);
const char *name = DICTOOL->getStringValue_json(json, A_NAME);
if(name != nullptr)
{
((SpriteDisplayData *)displayData)->displayName = name;
}
const rapidjson::Value &dicArray = DICTOOL->getSubDictionary_json(json, SKIN_DATA);
if(!dicArray.IsNull())
{
rapidjson::SizeType index = 0;
const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(dicArray, index);
if (!dic.IsNull())
{
SpriteDisplayData *sdd = (SpriteDisplayData *)displayData;
sdd->skinData.x = DICTOOL->getFloatValue_json(dic, A_X) * s_PositionReadScale;
sdd->skinData.y = DICTOOL->getFloatValue_json(dic, A_Y) * s_PositionReadScale;
sdd->skinData.scaleX = DICTOOL->getFloatValue_json(dic, A_SCALE_X, 1.0f);
sdd->skinData.scaleY = DICTOOL->getFloatValue_json(dic, A_SCALE_Y, 1.0f);
sdd->skinData.skewX = DICTOOL->getFloatValue_json(dic, A_SKEW_X, 1.0f);
sdd->skinData.skewY = DICTOOL->getFloatValue_json(dic, A_SKEW_Y, 1.0f);
if(json.HasMember(SKIN_DATA))
{
const rapidjson::Value &dicArray = DICTOOL->getSubDictionary_json(json, SKIN_DATA);
if(!dicArray.IsNull())
{
rapidjson::SizeType index = 0;
const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(dicArray, index);
if (!dic.IsNull())
{
SpriteDisplayData *sdd = (SpriteDisplayData *)displayData;
sdd->skinData.x = DICTOOL->getFloatValue_json(dic, A_X) * s_PositionReadScale;
sdd->skinData.y = DICTOOL->getFloatValue_json(dic, A_Y) * s_PositionReadScale;
sdd->skinData.scaleX = DICTOOL->getFloatValue_json(dic, A_SCALE_X, 1.0f);
sdd->skinData.scaleY = DICTOOL->getFloatValue_json(dic, A_SCALE_Y, 1.0f);
sdd->skinData.skewX = DICTOOL->getFloatValue_json(dic, A_SKEW_X, 1.0f);
sdd->skinData.skewY = DICTOOL->getFloatValue_json(dic, A_SKEW_Y, 1.0f);
sdd->skinData.x *= dataInfo->contentScale;
sdd->skinData.y *= dataInfo->contentScale;
}
}
sdd->skinData.x *= dataInfo->contentScale;
sdd->skinData.y *= dataInfo->contentScale;
}
}
}

View File

@ -340,12 +340,16 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
createObject(subDict, gb, attachComponent);
}
const rapidjson::Value &canvasSizeDict = DICTOOL->getSubDictionary_json(dict, "CanvasSize");
if (DICTOOL->checkObjectExist_json(canvasSizeDict))
if(dict.HasMember("CanvasSize"))
{
int width = DICTOOL->getIntValue_json(canvasSizeDict, "_width");
int height = DICTOOL->getIntValue_json(canvasSizeDict, "_height");
gb->setContentSize(Size(width, height));
const rapidjson::Value &canvasSizeDict = DICTOOL->getSubDictionary_json(dict, "CanvasSize");
if (DICTOOL->checkObjectExist_json(canvasSizeDict))
{
int width = DICTOOL->getIntValue_json(canvasSizeDict, "_width");
int height = DICTOOL->getIntValue_json(canvasSizeDict, "_height");
gb->setContentSize(Size(width, height));
}
}
return gb;

View File

@ -1791,7 +1791,7 @@ inline flatbuffers::Offset<ListViewOptions> CreateListViewOptions(flatbuffers::F
struct ProjectNodeOptions : private flatbuffers::Table {
const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); }
const flatbuffers::String *fileName() const { return GetPointer<const flatbuffers::String *>(6); }
float innerActionSpeed() const { return GetField<float>(8, 1.0); }
float innerActionSpeed() const { return GetField<float>(8, 0); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) &&
@ -1808,7 +1808,7 @@ struct ProjectNodeOptionsBuilder {
flatbuffers::uoffset_t start_;
void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); }
void add_fileName(flatbuffers::Offset<flatbuffers::String> fileName) { fbb_.AddOffset(6, fileName); }
void add_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement<float>(8, innerActionSpeed, 1.0); }
void add_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement<float>(8, innerActionSpeed, 0); }
ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &);
flatbuffers::Offset<ProjectNodeOptions> Finish() {
@ -1820,7 +1820,7 @@ struct ProjectNodeOptionsBuilder {
inline flatbuffers::Offset<ProjectNodeOptions> CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<WidgetOptions> nodeOptions = 0,
flatbuffers::Offset<flatbuffers::String> fileName = 0,
float innerActionSpeed = 1.0) {
float innerActionSpeed = 0) {
ProjectNodeOptionsBuilder builder_(_fbb);
builder_.add_innerActionSpeed(innerActionSpeed);
builder_.add_fileName(fileName);

View File

@ -24,6 +24,8 @@
#define NULL ((void *)0)
#endif
#endif
#elif defined(_SHARED_)
#define CC_STUDIO_DLL __attribute__((visibility("default")))
#else
#define CC_STUDIO_DLL
#endif

View File

@ -85,15 +85,15 @@ namespace cocostudio
attriname = attribute->Name();
std::string value = attribute->Value();
if (attriname == "ValueX")
if (attriname == "X")
{
ret.x = atof(value.c_str());
}
else if (attriname == "ValueY")
else if (attriname == "Y")
{
ret.y = atof(value.c_str());
}
else if(attriname == "ValueZ")
else if(attriname == "Z")
{
ret.z = atof(value.c_str());
}
@ -196,11 +196,11 @@ namespace cocostudio
attriname = attribute->Name();
std::string value = attribute->Value();
if (attriname == "ValueX")
if (attriname == "X")
{
position.x = atof(value.c_str());
}
else if (attriname == "ValueY")
else if (attriname == "Y")
{
position.y = atof(value.c_str());
}
@ -217,11 +217,11 @@ namespace cocostudio
attriname = attribute->Name();
std::string value = attribute->Value();
if (attriname == "ValueX")
if (attriname == "X")
{
scale.x = atof(value.c_str());
}
else if (attriname == "ValueY")
else if (attriname == "Y")
{
scale.y = atof(value.c_str());
}

View File

@ -85,11 +85,11 @@ namespace cocostudio
attriname = attribute->Name();
std::string value = attribute->Value();
if (attriname == "ValueX")
if (attriname == "X")
{
ret.x = atof(value.c_str());
}
else if (attriname == "ValueY")
else if (attriname == "Y")
{
ret.y = atof(value.c_str());
}

View File

@ -84,11 +84,11 @@ namespace cocostudio
attriname = attribute->Name();
std::string value = attribute->Value();
if (attriname == "ValueX")
if (attriname == "X")
{
ret.x = atof(value.c_str());
}
else if (attriname == "ValueY")
else if (attriname == "Y")
{
ret.y = atof(value.c_str());
}

View File

@ -95,16 +95,15 @@ public final class Cocos2dxBitmap {
hAlignment = Layout.Alignment.ALIGN_CENTER;
break;
case HORIZONTAL_ALIGN_RIGHT:
hAlignment = Layout.Alignment.valueOf("ALIGN_RIGHT");
hAlignment = Layout.Alignment.ALIGN_OPPOSITE;
break;
case HORIZONTAL_ALIGN_LEFT:
hAlignment = Layout.Alignment.valueOf("ALIGN_LEFT");
break;
default:
break;
}
TextPaint paint = Cocos2dxBitmap.newPaint(fontName, fontSize, horizontalAlignment);
TextPaint paint = Cocos2dxBitmap.newPaint(fontName, fontSize);
if (stroke) {
paint.setStyle(TextPaint.Style.STROKE);
paint.setStrokeWidth(strokeSize);
@ -164,8 +163,7 @@ public final class Cocos2dxBitmap {
return true;
}
private static TextPaint newPaint(final String fontName, final int fontSize,
final int horizontalAlignment) {
private static TextPaint newPaint(final String fontName, final int fontSize) {
final TextPaint paint = new TextPaint();
paint.setTextSize(fontSize);
paint.setAntiAlias(true);

View File

@ -42,7 +42,7 @@ THE SOFTWARE.
#define LOG_TAG "main"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
void cocos_android_app_init(JNIEnv* env, jobject thiz) __attribute__((weak));
void cocos_android_app_init(JNIEnv* env) __attribute__((weak));
using namespace cocos2d;
@ -53,6 +53,8 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
{
JniHelper::setJavaVM(vm);
cocos_android_app_init(JniHelper::getEnv());
return JNI_VERSION_1_4;
}
@ -66,8 +68,6 @@ JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, j
glview->setFrameSize(w, h);
director->setOpenGLView(glview);
//cocos_android_app_init(env, thiz);
cocos2d::Application::getInstance()->run();
}
else
@ -85,7 +85,6 @@ JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, j
JNIEXPORT jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNIEnv* env, jobject thiz)
{
cocos_android_app_init(env, thiz);
cocos2d::Application::getInstance()->initGLContextAttrs();
GLContextAttrs _glContextAttrs = GLView::getGLContextAttrs();

View File

@ -1427,7 +1427,7 @@ const Rect& Texture2D::getSpriteFrameCapInset( cocos2d::SpriteFrame *spriteFrame
}
else
{
auto capInsetMap = this->_ninePatchInfo->capInsetMap;
auto &capInsetMap = this->_ninePatchInfo->capInsetMap;
if(capInsetMap.find(spriteFrame) != capInsetMap.end())
{
return capInsetMap.at(spriteFrame);

View File

@ -108,7 +108,13 @@ void TextureCache::addImageAsync(const std::string &path, const std::function<vo
if (texture != nullptr)
{
callback(texture);
if (callback) callback(texture);
return;
}
// check if file exists
if ( fullpath.empty() || ! FileUtils::getInstance()->isFileExist( fullpath ) ) {
if (callback) callback(nullptr);
return;
}

View File

@ -1292,9 +1292,29 @@
var get3DVector = function(json, name, defValue){
var x = defValue, y = defValue, z = defValue;
if(json && name && json[name]){
x = null != json[name]["ValueX"] ? json[name]["ValueX"] : defValue;
y = null != json[name]["ValueY"] ? json[name]["ValueY"] : defValue;
z = null != json[name]["ValueZ"] ? json[name]["ValueZ"] : defValue;
if(undefined !== json[name]["ValueX"]) {
x = json[name]["ValueX"];
} else if(undefined !== json[name]["X"]) {
x = json[name]["X"]
}
if(null === x || isNaN(x))
x = defValue;
if(undefined !== json[name]["ValueY"]) {
y = json[name]["ValueY"];
} else if(undefined !== json[name]["Y"]) {
y = json[name]["Y"]
}
if(null === y || isNaN(y))
y = defValue;
if(undefined !== json[name]["ValueZ"]) {
z = json[name]["ValueZ"];
} else if(undefined !== json[name]["Z"]) {
z = json[name]["Z"]
}
if(null === z || isNaN(z))
z = defValue;
}
var vec3 = cc.math.vec3(x, y, z);
return vec3;
@ -1343,8 +1363,18 @@
var nearClip = 1;
var farClip = 500;
if(json["ClipPlane"]){
nearClip = json["ClipPlane"]["ValueX"];
farClip = json["ClipPlane"]["ValueY"];
if(undefined !== json["ClipPlane"]["ValueX"]) {
nearClip = json["ClipPlane"]["ValueX"];
} else if(undefined !== json["ClipPlane"]["X"]) {
nearClip = json["ClipPlane"]["X"];
}
if(undefined !== json["ClipPlane"]["ValueY"]) {
farClip = json["ClipPlane"]["ValueY"];
} else if(undefined !== json["ClipPlane"]["Y"]) {
farClip = json["ClipPlane"]["Y"];
}
if(null === nearClip || isNaN(nearClip))
nearClip = 1;
if(null === farClip || isNaN(farClip))

View File

@ -151,7 +151,7 @@ namespace ui {
auto spriteFrame = sprite->getSpriteFrame();
if (texture->isContain9PatchInfo())
{
auto parsedCapInset = texture->getSpriteFrameCapInset(spriteFrame);
auto& parsedCapInset = texture->getSpriteFrameCapInset(spriteFrame);
if(!parsedCapInset.equals(Rect::ZERO))
{
this->_isPatch9 = true;

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -10,7 +10,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -11,7 +11,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -11,7 +11,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -10,7 +10,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -10,7 +10,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -531,17 +531,17 @@ std::string BackgroundComponentTest::title() const
void BackgroundComponentTest::onEnter()
{
SceneEditorTestBase::onEnter();
do
{
do
{
Node *root = createGameScene();
CC_BREAK_IF(!root);
this->addChild(root, 0, 1);
} while (0);
} while (0);
}
void BackgroundComponentTest::onExit()
{
ArmatureDataManager::destroyInstance();
ArmatureDataManager::destroyInstance();
SceneReader::destroyInstance();
ActionManagerEx::destroyInstance();
GUIReader::destroyInstance();
@ -550,20 +550,20 @@ void BackgroundComponentTest::onExit()
cocos2d::Node* BackgroundComponentTest::createGameScene()
{
_filePath = "scenetest/BackgroundComponentTest/BackgroundComponentTest.json";
_filePath = "scenetest/BackgroundComponentTest/BackgroundComponentTest.json";
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
{
return nullptr;
}
defaultPlay();
if (_rootNode == nullptr)
{
return nullptr;
}
defaultPlay();
return _rootNode;
}
void BackgroundComponentTest::defaultPlay()
{
ComAudio *Audio = static_cast<ComAudio*>(_rootNode->getComponent("CCBackgroundAudio"));
Audio->playBackgroundMusic();
ComAudio *Audio = static_cast<ComAudio*>(_rootNode->getComponent("CCBackgroundAudio"));
Audio->playBackgroundMusic();
}
@ -584,13 +584,13 @@ std::string AttributeComponentTest::title() const
void AttributeComponentTest::onEnter()
{
SceneEditorTestBase::onEnter();
do
{
do
{
Node *root = createGameScene();
CC_BREAK_IF(!root);
defaultPlay();
defaultPlay();
this->addChild(root, 0, 1);
} while (0);
} while (0);
}
void AttributeComponentTest::onExit()
@ -604,33 +604,33 @@ void AttributeComponentTest::onExit()
bool AttributeComponentTest::initData()
{
bool bRet = false;
rapidjson::Document doc;
do {
CC_BREAK_IF(_rootNode == nullptr);
ComAttribute *attribute = static_cast<ComAttribute*>(_rootNode->getChildByTag(10015)->getComponent("CCComAttribute"));
CC_BREAK_IF(attribute == nullptr);
log("Name: %s, HP: %f, MP: %f", attribute->getString("name").c_str(), attribute->getFloat("maxHP"), attribute->getFloat("maxMP"));
bool bRet = false;
rapidjson::Document doc;
do {
CC_BREAK_IF(_rootNode == nullptr);
ComAttribute *attribute = static_cast<ComAttribute*>(_rootNode->getChildByTag(10015)->getComponent("CCComAttribute"));
CC_BREAK_IF(attribute == nullptr);
log("Name: %s, HP: %f, MP: %f", attribute->getString("name").c_str(), attribute->getFloat("maxHP"), attribute->getFloat("maxMP"));
bRet = true;
} while (0);
return bRet;
bRet = true;
} while (0);
return bRet;
}
cocos2d::Node* AttributeComponentTest::createGameScene()
{
_filePath = "scenetest/AttributeComponentTest/AttributeComponentTest.json";
_filePath = "scenetest/AttributeComponentTest/AttributeComponentTest.json";
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
{
return nullptr;
}
if (_rootNode == nullptr)
{
return nullptr;
}
return _rootNode;
}
void AttributeComponentTest::defaultPlay()
{
initData();
initData();
}
TriggerTest::TriggerTest()
@ -652,7 +652,7 @@ std::string TriggerTest::title() const
// on "init" you need to initialize your instance
void TriggerTest::onEnter()
{
SceneEditorTestBase::onEnter();
SceneEditorTestBase::onEnter();
Node *root = createGameScene();
this->addChild(root, 0, 1);
this->schedule(CC_SCHEDULE_SELECTOR(TriggerTest::gameLogic));
@ -670,12 +670,12 @@ void TriggerTest::onEnter()
void TriggerTest::onExit()
{
sendEvent(TRIGGEREVENT_LEAVESCENE);
sendEvent(TRIGGEREVENT_LEAVESCENE);
this->unschedule(CC_SCHEDULE_SELECTOR(TriggerTest::gameLogic));
auto dispatcher = Director::getInstance()->getEventDispatcher();
dispatcher->removeEventListener(_touchListener);
Device::setAccelerometerEnabled(false);
ArmatureDataManager::destroyInstance();
ArmatureDataManager::destroyInstance();
SceneReader::destroyInstance();
ActionManagerEx::destroyInstance();
GUIReader::destroyInstance();
@ -711,14 +711,14 @@ void TriggerTest::gameLogic(float dt)
cocos2d::Node* TriggerTest::createGameScene()
{
_filePath = "scenetest/TriggerTest/TriggerTest.json";
_filePath = "scenetest/TriggerTest/TriggerTest.json";
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
{
return nullptr;
}
if (_rootNode == nullptr)
{
return nullptr;
}
defaultPlay();
defaultPlay();
return _rootNode;
}
void TriggerTest::defaultPlay()

View File

@ -2000,6 +2000,7 @@ void ParticleIssue12310::onEnter()
addChild(particle);
_emitter = particle;
_emitter->retain();
auto particle2 = ParticleSystemQuad::create("Particles/BoilingFoamStar.plist");
particle2->setPosition(Vec2(winSize.width * 0.65f, winSize.height * 0.5f));

View File

@ -8,14 +8,14 @@ DEFINE_TEST_SUITE(ParticleTests);
class ParticleDemo : public TestCase
{
protected:
cocos2d::ParticleSystemQuad* _emitter;
cocos2d::Sprite* _background;
cocos2d::LayerColor* _color;
cocos2d::ParticleSystemQuad* _emitter;
cocos2d::Sprite* _background;
cocos2d::LayerColor* _color;
public:
~ParticleDemo(void);
~ParticleDemo();
virtual void onEnter(void);
virtual void onEnter();
virtual std::string title() const override;
virtual std::string subtitle() const override;

View File

@ -90,8 +90,6 @@ bool Scene3DTestScene::init()
{
CC_BREAK_IF(false == TerrainWalkThru::init());
Director::getInstance()->setDisplayStats(false);
// prepare for camera creation, we need create three custom cameras
_gameCameras.resize(LAYER_COUNT);

View File

@ -232,8 +232,7 @@ bool UITextTest_IgnoreConentSize::init()
widgetSize.height / 2.0f));
leftText->ignoreContentAdaptWithSize(false);
leftText->setTextAreaSize(Size(60,60));
leftText->setString("Text line with break\nText line \
with break\nText line with break\nText line with break\n");
leftText->setString("Text line with break\nText line with break\nText line with break\nText line with break\n");
leftText->setTouchScaleChangeEnabled(true);
leftText->setTouchEnabled(true);
_uiLayer->addChild(leftText);
@ -243,8 +242,7 @@ bool UITextTest_IgnoreConentSize::init()
"fonts/Marker Felt.ttf",10);
rightText->setPosition(Vec2(widgetSize.width / 2.0f + 50,
widgetSize.height / 2.0f));
rightText->setString("Text line with break\nText line \
with break\nText line with break\nText line with break\n");
rightText->setString("Text line with break\nText line with break\nText line with break\nText line with break\n");
//note:setTextAreaSize must be used with ignoreContentAdaptWithSize(false)
rightText->setTextAreaSize(Size(100,30));
rightText->ignoreContentAdaptWithSize(false);

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -10,7 +10,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -10,7 +10,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
JavaVM* vm;

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
JavaVM* vm;

View File

@ -5338,10 +5338,10 @@ var SpriteBlendFuncTest = SpriteTestDemo.extend({
//----start59----ctor
this._super();
var destFactors = [gl.ZERO, gl.ONE, gl.SRC_COLOR, gl.ONE_MINUS_SRC_COLOR, gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA],
srcFactors = [gl.ZERO, gl.ONE, gl.DST_COLOR, gl.ONE_MINUS_DST_COLOR, gl.DST_ALPHA, gl.ONE_MINUS_DST_ALPHA];
var destTitles = ["ZERO", "ONE", "SRC_COLOR", "ONE_MINUS_SRC_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA"],
srcTitles = ["ZERO", "ONE", "DST_COLOR", "ONE_MINUS_DST_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA"];
var destFactors = [cc.ZERO, cc.ONE, cc.DST_COLOR, cc.ONE_MINUS_DST_COLOR, cc.DST_ALPHA, cc.ONE_MINUS_DST_ALPHA],
srcFactors = [cc.ZERO, cc.ONE, cc.SRC_COLOR, cc.ONE_MINUS_SRC_COLOR, cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA];
var destTitles = ["ZERO", "ONE", "DST_COLOR", "ONE_MINUS_DST_COLOR", "DST_ALPHA", "ONE_MINUS_DST_ALPHA"],
srcTitles = ["ZERO", "ONE", "SRC_COLOR", "ONE_MINUS_SRC_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA"];
var sourceImg = "Images/dot.png", destImg = "Images/wood.jpg";
var sourceTexture = cc.textureCache.addImage(sourceImg);
@ -5355,6 +5355,14 @@ var SpriteBlendFuncTest = SpriteTestDemo.extend({
this.addChild(sourceSprite);
this.addChild(destSprite);
if(cc._renderType === cc._RENDER_TYPE_CANVAS){
var info = new cc.LabelTTF("support is not complete on canvas", "Arial", 18);
info.x = 680;
info.y = 250;
info.setDimensions(cc.size(200, 200));
this.addChild(info);
}
var i, j, title, fontSize, titleLabel;
for(i = 0; i < destTitles.length; i++){
title = destTitles[i];

View File

@ -179,6 +179,10 @@ var transitionsIdx = 0;
// every .Scene each test used must inherit from TestScene,
// make sure the test have the menu item for back to main menu
var TransitionsTestScene = TestScene.extend({
onEnter: function () {
this._super();
director.setDepthTest(false);
},
runThisTest:function () {
var layer = new TestLayer1();
this.addChild(layer);

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new (std::nothrow) AppDelegate();
}

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new (std::nothrow) AppDelegate();
}

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -9,7 +9,7 @@
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

View File

@ -1235,17 +1235,20 @@ function LabelCharMapTest.create()
local label1 = cc.Label:createWithCharMap("fonts/tuffy_bold_italic-charmap.plist")
layer:addChild(label1, 0, kTagSprite1)
label1:setAnchorPoint(cc.p(0, 0))
label1:setPosition( cc.p(10,100) )
label1:setOpacity( 200 )
local label2 = cc.Label:createWithCharMap("fonts/tuffy_bold_italic-charmap.plist")
layer:addChild(label2, 0, kTagSprite2)
label2:setAnchorPoint(cc.p(0, 0))
label2:setPosition( cc.p(10,160) )
label2:setOpacity( 32 )
local label3 = cc.Label:createWithCharMap("fonts/tuffy_bold_italic-charmap.plist")--32 means Space key
label3:setString("123 Test")
layer:addChild(label3, 0, kTagSprite3)
label3:setAnchorPoint(cc.p(0, 0))
label3:setPosition(cc.p(10,220))
local function step(dt)

View File

@ -14,6 +14,9 @@ import traceback
from os import path, extsep
from subprocess import Popen, PIPE, CalledProcessError
def os_is_win32():
return sys.platform == 'win32'
class UnrecognizedFormat:
def __init__(self, prompt):
self._prompt = prompt
@ -66,7 +69,7 @@ class GitArchiver(object):
# Raises an exception if there is no repo under main_repo_abspath.
try:
self.run_shell("[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1", main_repo_abspath)
self.run_shell("git rev-parse", main_repo_abspath)
except Exception as e:
raise ValueError("Not a git repository (or any of the parent directories).".format(path=main_repo_abspath))
@ -188,7 +191,11 @@ class GitArchiver(object):
if self.verbose:
print("Compressing {f} => {a}...".format(f=file_path,
a=path.join(self.prefix, file_path)))
add(file_path, file_path)
try:
add(file_path, file_path)
except:
print('add %s failed.' % file_path)
pass
else:
print("{f} => {a}".format(f=file_path,
a=path.join(self.prefix, file_path)))
@ -199,7 +206,11 @@ class GitArchiver(object):
print("Compressing {f} => {a}...".format(f=path.join(self.main_repo_abspath, file_path),
a=path.join(self.prefix, file_path)))
add(path.join(self.main_repo_abspath, file_path), file_path)
try:
add(path.join(self.main_repo_abspath, file_path), file_path)
except:
print('add %s failed.' % file_path)
pass
else:
print("{f} => {a}".format(f=path.join(self.main_repo_abspath, file_path),
a=path.join(self.prefix, file_path)))
@ -232,7 +243,12 @@ class GitArchiver(object):
raise Exception("Couldn't find extra folder path (%s) in (%s)!" % (extra_folder_path, file_path))
path_in_zip = extra_to_zip_file + file_path[(len(extra_folder_path)):]
add(file_path, path_in_zip)
try:
add(file_path, path_in_zip)
except:
print('add %s failed.' % file_path)
pass
outfile_name, outfile_ext = path.splitext(output_path)
for extra_dir in config_data["extra_dirs"]:
@ -242,7 +258,11 @@ class GitArchiver(object):
for f in files:
file_path = path.join(root,f)
path_in_zip = file_path[(len(self.main_repo_abspath)+1):]
add(file_path, path_in_zip)
try:
add(file_path, path_in_zip)
except:
print('add %s failed.' % file_path)
pass
if not dry_run:
archive.close()
@ -273,11 +293,20 @@ class GitArchiver(object):
"""
components = []
while not path.samefile(abspath, repo_abspath):
abspath, tail = path.split(abspath)
if os_is_win32():
abspath = os.path.normpath(abspath)
repo_abspath = os.path.normpath(repo_abspath)
while abspath != repo_abspath:
abspath, tail = path.split(abspath)
if len(tail):
components.insert(0, tail)
if len(tail):
components.insert(0, tail)
else:
while not path.samefile(abspath, repo_abspath):
abspath, tail = path.split(abspath)
if len(tail):
components.insert(0, tail)
components.insert(0, path.relpath(repo_abspath, repo_abspath))
return components