From eca488b85a9b90393e582d0192eafb013a2cc8ae Mon Sep 17 00:00:00 2001 From: Justin Hawkwood Date: Mon, 8 Jun 2015 17:14:15 -0700 Subject: [PATCH 01/22] Fails if file does not exist This adds a callback with nullptr if the file does not exists. Checking this before checking cache means that if a file is cached then deleted, the async call will fail. To allow a cached but deleted file to return the texture, move the isFileExist check to ALTERNATIVE. If leaving check where it is, on failure should it also check if the file was cached and remove it? --- cocos/renderer/CCTextureCache.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cocos/renderer/CCTextureCache.cpp b/cocos/renderer/CCTextureCache.cpp index 7afca3874e..c4a77786cc 100644 --- a/cocos/renderer/CCTextureCache.cpp +++ b/cocos/renderer/CCTextureCache.cpp @@ -102,6 +102,12 @@ void TextureCache::addImageAsync(const std::string &path, const std::functionfullPathForFilename(path); + // check if file exists + if (! FileUtils::getInstance()->isFileExist( fullpath )) { + callback(nullptr); + return; + } + auto it = _textures.find(fullpath); if( it != _textures.end() ) texture = it->second; @@ -112,6 +118,8 @@ void TextureCache::addImageAsync(const std::string &path, const std::function Date: Tue, 9 Jun 2015 09:19:04 -0700 Subject: [PATCH 02/22] Added empty string check --- cocos/renderer/CCTextureCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/renderer/CCTextureCache.cpp b/cocos/renderer/CCTextureCache.cpp index c4a77786cc..1956c1d395 100644 --- a/cocos/renderer/CCTextureCache.cpp +++ b/cocos/renderer/CCTextureCache.cpp @@ -103,7 +103,7 @@ void TextureCache::addImageAsync(const std::string &path, const std::functionfullPathForFilename(path); // check if file exists - if (! FileUtils::getInstance()->isFileExist( fullpath )) { + if ( fullpath.empty() || ! FileUtils::getInstance()->isFileExist( fullpath ) ) { callback(nullptr); return; } From 9378b6704c575123e158369f19f81180601e1517 Mon Sep 17 00:00:00 2001 From: Justin Hawkwood Date: Mon, 15 Jun 2015 23:31:52 -0700 Subject: [PATCH 03/22] Moved file check to alternate location --- cocos/renderer/CCTextureCache.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cocos/renderer/CCTextureCache.cpp b/cocos/renderer/CCTextureCache.cpp index 1956c1d395..a7101f1ac2 100644 --- a/cocos/renderer/CCTextureCache.cpp +++ b/cocos/renderer/CCTextureCache.cpp @@ -102,12 +102,6 @@ void TextureCache::addImageAsync(const std::string &path, const std::functionfullPathForFilename(path); - // check if file exists - if ( fullpath.empty() || ! FileUtils::getInstance()->isFileExist( fullpath ) ) { - callback(nullptr); - return; - } - auto it = _textures.find(fullpath); if( it != _textures.end() ) texture = it->second; @@ -118,7 +112,11 @@ void TextureCache::addImageAsync(const std::string &path, const std::functionisFileExist( fullpath ) ) { + callback(nullptr); + return; + } // lazy init if (_asyncStructQueue == nullptr) From 90db6fe5d6b433e282bd707737e65f6341465ca8 Mon Sep 17 00:00:00 2001 From: Justin Hawkwood Date: Mon, 15 Jun 2015 23:36:04 -0700 Subject: [PATCH 04/22] Added check that callback is set --- cocos/renderer/CCTextureCache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/renderer/CCTextureCache.cpp b/cocos/renderer/CCTextureCache.cpp index a7101f1ac2..446061784e 100644 --- a/cocos/renderer/CCTextureCache.cpp +++ b/cocos/renderer/CCTextureCache.cpp @@ -108,13 +108,13 @@ void TextureCache::addImageAsync(const std::string &path, const std::functionisFileExist( fullpath ) ) { - callback(nullptr); + if (callback) callback(nullptr); return; } From d2522509686223a22c4a54e02cc5002a0cd209cc Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 19 Jun 2015 18:46:14 +0800 Subject: [PATCH 05/22] quaternion instead of euler angle --- cocos/2d/CCCamera.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cocos/2d/CCCamera.cpp b/cocos/2d/CCCamera.cpp index b5eacd7a93..ca8d0dc6d2 100644 --- a/cocos/2d/CCCamera.cpp +++ b/cocos/2d/CCCamera.cpp @@ -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 From 4a15d570933543eaf04fb508100f7217903d0377 Mon Sep 17 00:00:00 2001 From: Anniruddh Date: Sat, 20 Jun 2015 00:20:15 -0700 Subject: [PATCH 06/22] Fixed issue #168 --- cocos/audio/winrt/Audio.cpp | 65 ++++++++++++++------------ cocos/audio/winrt/AudioCachePlayer.cpp | 37 +++++++++------ 2 files changed, 59 insertions(+), 43 deletions(-) diff --git a/cocos/audio/winrt/Audio.cpp b/cocos/audio/winrt/Audio.cpp index 13ed507632..1dd1332b70 100644 --- a/cocos/audio/winrt/Audio.cpp +++ b/cocos/audio/winrt/Audio.cpp @@ -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); } diff --git a/cocos/audio/winrt/AudioCachePlayer.cpp b/cocos/audio/winrt/AudioCachePlayer.cpp index 0be13433dd..d6dbbd3af5 100644 --- a/cocos/audio/winrt/AudioCachePlayer.cpp +++ b/cocos/audio/winrt/AudioCachePlayer.cpp @@ -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() From fbe1bd825363e363c148b51cd341db2690569b4d Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 23 Jun 2015 09:42:48 +0800 Subject: [PATCH 07/22] Label should be invisible when the line height is set to zero. --- cocos/2d/CCLabel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index f1e674876e..331bed2b27 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -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); From 931011809d852190a5ceaa6c2b9ed0dbc0f5ad15 Mon Sep 17 00:00:00 2001 From: andyque Date: Tue, 23 Jun 2015 10:38:43 +0800 Subject: [PATCH 08/22] fixed unintended spaces in string --- .../UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp index 40fb111518..603121c565 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp @@ -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); From a68874d3cbb2daf13d3ff65838e4ded6a9b031ed Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 23 Jun 2015 11:00:23 +0800 Subject: [PATCH 09/22] Node: Particles --> ParticleIssue12310:Fixed crash when tap left/right arrow to move to another test case. --- tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp | 1 + tests/cpp-tests/Classes/ParticleTest/ParticleTest.h | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp index a085325fb1..ecaa86d5e4 100644 --- a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp +++ b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp @@ -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)); diff --git a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h index 8cab2e5ef3..56d4220c8f 100644 --- a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h +++ b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h @@ -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; From 375e80bd70850f51097756ce90d6651f8fe284bf Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Tue, 23 Jun 2015 11:31:16 +0800 Subject: [PATCH 10/22] Update 3d reader for compatible with cocosstudio 3.1.2 version csd file Update easing default speed --- .../cocostudio/CSParseBinary_generated.h | 6 +++--- .../editor-support/cocostudio/CocosStudioExport.h | 2 ++ .../WidgetReader/Node3DReader/Node3DReader.cpp | 14 +++++++------- .../WidgetReader/Sprite3DReader/Sprite3DReader.cpp | 4 ++-- .../UserCameraReader/UserCameraReader.cpp | 4 ++-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cocos/editor-support/cocostudio/CSParseBinary_generated.h b/cocos/editor-support/cocostudio/CSParseBinary_generated.h index 7a553be9bb..ba6b4197c6 100644 --- a/cocos/editor-support/cocostudio/CSParseBinary_generated.h +++ b/cocos/editor-support/cocostudio/CSParseBinary_generated.h @@ -1791,7 +1791,7 @@ inline flatbuffers::Offset CreateListViewOptions(flatbuffers::F struct ProjectNodeOptions : private flatbuffers::Table { const WidgetOptions *nodeOptions() const { return GetPointer(4); } const flatbuffers::String *fileName() const { return GetPointer(6); } - float innerActionSpeed() const { return GetField(8, 1.0); } + float innerActionSpeed() const { return GetField(8, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* nodeOptions */) && @@ -1808,7 +1808,7 @@ struct ProjectNodeOptionsBuilder { flatbuffers::uoffset_t start_; void add_nodeOptions(flatbuffers::Offset nodeOptions) { fbb_.AddOffset(4, nodeOptions); } void add_fileName(flatbuffers::Offset fileName) { fbb_.AddOffset(6, fileName); } - void add_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement(8, innerActionSpeed, 1.0); } + void add_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement(8, innerActionSpeed, 0); } ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &); flatbuffers::Offset Finish() { @@ -1820,7 +1820,7 @@ struct ProjectNodeOptionsBuilder { inline flatbuffers::Offset CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset nodeOptions = 0, flatbuffers::Offset fileName = 0, - float innerActionSpeed = 1.0) { + float innerActionSpeed = 0) { ProjectNodeOptionsBuilder builder_(_fbb); builder_.add_innerActionSpeed(innerActionSpeed); builder_.add_fileName(fileName); diff --git a/cocos/editor-support/cocostudio/CocosStudioExport.h b/cocos/editor-support/cocostudio/CocosStudioExport.h index c22591f6b5..20bc6f5038 100644 --- a/cocos/editor-support/cocostudio/CocosStudioExport.h +++ b/cocos/editor-support/cocostudio/CocosStudioExport.h @@ -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 diff --git a/cocos/editor-support/cocostudio/WidgetReader/Node3DReader/Node3DReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/Node3DReader/Node3DReader.cpp index 9047de4d88..5435505e48 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/Node3DReader/Node3DReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/Node3DReader/Node3DReader.cpp @@ -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()); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp index b1f511ccf8..618811f1c0 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp @@ -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()); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp index b571260938..6f3fa906e4 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp @@ -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()); } From a433d578075216e5453c3a033b6d59fcc5c902b7 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Tue, 23 Jun 2015 11:56:50 +0800 Subject: [PATCH 11/22] show fps --- tests/cpp-tests/Classes/Scene3DTest/Scene3DTest.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/cpp-tests/Classes/Scene3DTest/Scene3DTest.cpp b/tests/cpp-tests/Classes/Scene3DTest/Scene3DTest.cpp index 6d5e647aac..314da6b1dc 100644 --- a/tests/cpp-tests/Classes/Scene3DTest/Scene3DTest.cpp +++ b/tests/cpp-tests/Classes/Scene3DTest/Scene3DTest.cpp @@ -89,8 +89,6 @@ bool Scene3DTestScene::init() do { CC_BREAK_IF(false == TerrainWalkThru::init()); - - Director::getInstance()->setDisplayStats(false); // prepare for camera creation, we need create three custom cameras _gameCameras.resize(LAYER_COUNT); From 3381716232d2751fbeb0f2bbf9f1f39b766251c4 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 23 Jun 2015 05:22:46 +0000 Subject: [PATCH 12/22] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../lua-bindings/auto/api/Sprite.lua | 30 ++++ .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 145 ++++++++++++++++++ .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 3 + 3 files changed, 178 insertions(+) diff --git a/cocos/scripting/lua-bindings/auto/api/Sprite.lua b/cocos/scripting/lua-bindings/auto/api/Sprite.lua index 92bab73b70..44e61a83f3 100644 --- a/cocos/scripting/lua-bindings/auto/api/Sprite.lua +++ b/cocos/scripting/lua-bindings/auto/api/Sprite.lua @@ -261,6 +261,36 @@ -- @param #rect_table rect -- @return Sprite#Sprite self (return value: cc.Sprite) +-------------------------------- +-- @overload self, cc.Texture2D, rect_table, bool +-- @overload self, cc.Texture2D +-- @function [parent=#Sprite] createWithTexture +-- @param self +-- @param #cc.Texture2D texture +-- @param #rect_table rect +-- @param #bool rotated +-- @return Sprite#Sprite ret (return value: cc.Sprite) + +-------------------------------- +-- Creates a sprite with an sprite frame name.
+-- A SpriteFrame will be fetched from the SpriteFrameCache by spriteFrameName param.
+-- If the SpriteFrame doesn't exist it will raise an exception.
+-- param spriteFrameName A null terminated string which indicates the sprite frame name.
+-- return An autoreleased sprite object. +-- @function [parent=#Sprite] createWithSpriteFrameName +-- @param self +-- @param #string spriteFrameName +-- @return Sprite#Sprite ret (return value: cc.Sprite) + +-------------------------------- +-- Creates a sprite with an sprite frame.
+-- param spriteFrame A sprite frame which involves a texture and a rect.
+-- return An autoreleased sprite object. +-- @function [parent=#Sprite] createWithSpriteFrame +-- @param self +-- @param #cc.SpriteFrame spriteFrame +-- @return Sprite#Sprite ret (return value: cc.Sprite) + -------------------------------- -- @overload self, cc.Node, int, string -- @overload self, cc.Node, int, int diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 54a1af7a02..ecc989f40b 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -70206,6 +70206,148 @@ int lua_cocos2dx_Sprite_setVertexRect(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Sprite_createWithTexture(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S)-1; + + do + { + if (argc == 2) + { + cocos2d::Texture2D* arg0; + ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "cc.Sprite:createWithTexture"); + if (!ok) { break; } + cocos2d::Rect arg1; + ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Sprite:createWithTexture"); + if (!ok) { break; } + cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0, arg1); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + } while (0); + ok = true; + do + { + if (argc == 3) + { + cocos2d::Texture2D* arg0; + ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "cc.Sprite:createWithTexture"); + if (!ok) { break; } + cocos2d::Rect arg1; + ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Sprite:createWithTexture"); + if (!ok) { break; } + bool arg2; + ok &= luaval_to_boolean(tolua_S, 4,&arg2, "cc.Sprite:createWithTexture"); + if (!ok) { break; } + cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0, arg1, arg2); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + } while (0); + ok = true; + do + { + if (argc == 1) + { + cocos2d::Texture2D* arg0; + ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "cc.Sprite:createWithTexture"); + if (!ok) { break; } + cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + } while (0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite:createWithTexture",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_createWithTexture'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_Sprite_createWithSpriteFrameName(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite:createWithSpriteFrameName"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Sprite_createWithSpriteFrameName'", nullptr); + return 0; + } + cocos2d::Sprite* ret = cocos2d::Sprite::createWithSpriteFrameName(arg0); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite:createWithSpriteFrameName",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_createWithSpriteFrameName'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_Sprite_createWithSpriteFrame(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + cocos2d::SpriteFrame* arg0; + ok &= luaval_to_object(tolua_S, 2, "cc.SpriteFrame",&arg0, "cc.Sprite:createWithSpriteFrame"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Sprite_createWithSpriteFrame'", nullptr); + return 0; + } + cocos2d::Sprite* ret = cocos2d::Sprite::createWithSpriteFrame(arg0); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite:createWithSpriteFrame",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_createWithSpriteFrame'.",&tolua_err); +#endif + return 0; +} int lua_cocos2dx_Sprite_constructor(lua_State* tolua_S) { int argc = 0; @@ -70287,6 +70429,9 @@ int lua_register_cocos2dx_Sprite(lua_State* tolua_S) tolua_function(tolua_S,"isFlippedX",lua_cocos2dx_Sprite_isFlippedX); tolua_function(tolua_S,"isFlippedY",lua_cocos2dx_Sprite_isFlippedY); tolua_function(tolua_S,"setVertexRect",lua_cocos2dx_Sprite_setVertexRect); + tolua_function(tolua_S,"createWithTexture", lua_cocos2dx_Sprite_createWithTexture); + tolua_function(tolua_S,"createWithSpriteFrameName", lua_cocos2dx_Sprite_createWithSpriteFrameName); + tolua_function(tolua_S,"createWithSpriteFrame", lua_cocos2dx_Sprite_createWithSpriteFrame); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Sprite).name(); g_luaType[typeName] = "cc.Sprite"; diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 5bf82ddefb..945d7349d5 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2055,6 +2055,9 @@ int register_all_cocos2dx(lua_State* tolua_S); + + + From b275ce22832963aa15a9157376bd62682a33e9fa Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 23 Jun 2015 13:38:06 +0800 Subject: [PATCH 13/22] Label:Fixed IllegalArgumentException on Android 2.3.x --- .../android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java index 538881eecf..ea3cc94561 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java @@ -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); From 70b709f4a886d1efc583cc62f5dad215d4050600 Mon Sep 17 00:00:00 2001 From: andyque Date: Tue, 23 Jun 2015 13:54:11 +0800 Subject: [PATCH 14/22] fix rapidjson assert error --- .../editor-support/cocostudio/CCComRender.cpp | 335 +++++++++--------- .../cocostudio/CCDataReaderHelper.cpp | 40 ++- .../cocostudio/CCSSceneReader.cpp | 14 +- .../CocoStudioSceneTest/SceneEditorTest.cpp | 82 ++--- 4 files changed, 240 insertions(+), 231 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCComRender.cpp b/cocos/editor-support/cocostudio/CCComRender.cpp index b69e0570d2..9bab679e74 100644 --- a/cocos/editor-support/cocostudio/CCComRender.cpp +++ b/cocos/editor-support/cocostudio/CCComRender.cpp @@ -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; diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index dbeae98145..60c5aa6792 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -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; - } } } diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index 0e29de8d2f..593eaeba32 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -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; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index e74c790740..5dfdccba32 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -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(_rootNode->getComponent("CCBackgroundAudio")); - Audio->playBackgroundMusic(); + ComAudio *Audio = static_cast(_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(_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(_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() From 90f9bf37cdb0f89005206af37e1efbf3a871bb8a Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Tue, 23 Jun 2015 14:41:41 +0800 Subject: [PATCH 15/22] fix redmine issue #20277 RestartGameTest only used in native will crash --- cocos/base/CCDirector.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 0be71ab673..7ef479424c 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -1007,6 +1007,9 @@ void Director::restartDirector() { reset(); + // RenderState need to be reinitialized + RenderState::initialize(); + // Texture cache need to be reinitialized initTextureCache(); From 7fff2bd3c486572916e9af09e86dc436f36421bd Mon Sep 17 00:00:00 2001 From: andyque Date: Tue, 23 Jun 2015 15:42:58 +0800 Subject: [PATCH 16/22] fix nine patch image parser error on Windows. --- cocos/renderer/CCTexture2D.cpp | 2 +- cocos/ui/UIScale9Sprite.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/renderer/CCTexture2D.cpp b/cocos/renderer/CCTexture2D.cpp index f51b5ae199..634c7c0f1c 100644 --- a/cocos/renderer/CCTexture2D.cpp +++ b/cocos/renderer/CCTexture2D.cpp @@ -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); diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 6d0b91aeb1..bc5ad0843e 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -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; From 27d011dd501efca17d3fd0321c2d4fa148bb80b0 Mon Sep 17 00:00:00 2001 From: Vincent Yang Date: Tue, 23 Jun 2015 16:02:38 +0800 Subject: [PATCH 17/22] Fixbug: LabelTestNew New Label + CharMap's effect is wrong. --- tests/lua-tests/src/LabelTestNew/LabelTestNew.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/lua-tests/src/LabelTestNew/LabelTestNew.lua b/tests/lua-tests/src/LabelTestNew/LabelTestNew.lua index 40a2c9fed9..e61b88c6cd 100644 --- a/tests/lua-tests/src/LabelTestNew/LabelTestNew.lua +++ b/tests/lua-tests/src/LabelTestNew/LabelTestNew.lua @@ -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) From befe97a78b86f7ab2fa185dd535afaef8de3795b Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Tue, 23 Jun 2015 16:24:53 +0800 Subject: [PATCH 18/22] Update js parser for compatible with CocosStudio 2.3.2 json format export --- .../studio/parsers/timelineParser-2.x.js | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js index 056688225f..8a5f8e3079 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js @@ -1291,9 +1291,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; @@ -1342,8 +1362,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)) From cd1233f801fc7443ccde668497753fdcae7ab302 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 23 Jun 2015 16:58:15 +0800 Subject: [PATCH 19/22] Fix TransitionTest issue that depth test haven't been disabled after transition --- tests/js-tests/src/TransitionsTest/TransitionsTest.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/js-tests/src/TransitionsTest/TransitionsTest.js b/tests/js-tests/src/TransitionsTest/TransitionsTest.js index f6f0173e6b..772534f42f 100644 --- a/tests/js-tests/src/TransitionsTest/TransitionsTest.js +++ b/tests/js-tests/src/TransitionsTest/TransitionsTest.js @@ -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); From cbb073e905a7d9e621a247a558f012da3e3dc3f2 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 23 Jun 2015 16:58:38 +0800 Subject: [PATCH 20/22] Fixed Application may be created more than once on Android. --- cocos/platform/android/javaactivity-android.cpp | 7 +++---- .../proj.android-studio/app/jni/hellocpp/main.cpp | 2 +- .../proj.android/jni/hellocpp/main.cpp | 2 +- .../proj.android-studio/app/jni/hellojavascript/main.cpp | 2 +- .../runtime-src/proj.android/jni/hellojavascript/main.cpp | 2 +- .../runtime-src/proj.android/jni/hellojavascript/main.cpp | 2 +- .../proj.android-studio/app/jni/hellolua/main.cpp | 2 +- .../runtime-src/proj.android/jni/hellolua/main.cpp | 2 +- tests/cpp-empty-test/proj.android-studio/app/jni/main.cpp | 2 +- tests/cpp-empty-test/proj.android/jni/main.cpp | 2 +- tests/cpp-tests/proj.android-studio/app/jni/main.cpp | 2 +- tests/cpp-tests/proj.android/jni/main.cpp | 2 +- .../proj.android-studio/app/jni/main.cpp | 2 +- tests/game-controller-test/proj.android/jni/main.cpp | 2 +- .../js-tests/project/proj.android-studio/app/jni/main.cpp | 2 +- tests/js-tests/project/proj.android/jni/main.cpp | 2 +- .../project/proj.android-studio/app/jni/main.cpp | 2 +- tests/lua-empty-test/project/proj.android/jni/main.cpp | 2 +- .../project/proj.android-studio/app/jni/main.cpp | 2 +- .../project/proj.android/jni/main.cpp | 2 +- .../lua-tests/project/proj.android-studio/app/jni/main.cpp | 2 +- tests/lua-tests/project/proj.android/jni/main.cpp | 2 +- 22 files changed, 24 insertions(+), 25 deletions(-) diff --git a/cocos/platform/android/javaactivity-android.cpp b/cocos/platform/android/javaactivity-android.cpp index 5f710fd765..afcf93eca0 100644 --- a/cocos/platform/android/javaactivity-android.cpp +++ b/cocos/platform/android/javaactivity-android.cpp @@ -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(); diff --git a/templates/cpp-template-default/proj.android-studio/app/jni/hellocpp/main.cpp b/templates/cpp-template-default/proj.android-studio/app/jni/hellocpp/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/templates/cpp-template-default/proj.android-studio/app/jni/hellocpp/main.cpp +++ b/templates/cpp-template-default/proj.android-studio/app/jni/hellocpp/main.cpp @@ -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(); } diff --git a/templates/cpp-template-default/proj.android/jni/hellocpp/main.cpp b/templates/cpp-template-default/proj.android/jni/hellocpp/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/templates/cpp-template-default/proj.android/jni/hellocpp/main.cpp +++ b/templates/cpp-template-default/proj.android/jni/hellocpp/main.cpp @@ -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(); } diff --git a/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellojavascript/main.cpp b/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellojavascript/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellojavascript/main.cpp +++ b/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellojavascript/main.cpp @@ -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(); } diff --git a/templates/js-template-default/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp b/templates/js-template-default/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/templates/js-template-default/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp +++ b/templates/js-template-default/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp @@ -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(); } diff --git a/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp b/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp index bb3ea221bc..c721da8a60 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp +++ b/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp @@ -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(); } diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellolua/main.cpp b/templates/lua-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellolua/main.cpp index fff9f825a6..729b8b7f9a 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellolua/main.cpp +++ b/templates/lua-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellolua/main.cpp @@ -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(); } diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/hellolua/main.cpp b/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/hellolua/main.cpp index fff9f825a6..729b8b7f9a 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/hellolua/main.cpp +++ b/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/hellolua/main.cpp @@ -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(); } diff --git a/tests/cpp-empty-test/proj.android-studio/app/jni/main.cpp b/tests/cpp-empty-test/proj.android-studio/app/jni/main.cpp index feab560c09..4b0db09aa7 100644 --- a/tests/cpp-empty-test/proj.android-studio/app/jni/main.cpp +++ b/tests/cpp-empty-test/proj.android-studio/app/jni/main.cpp @@ -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(); } diff --git a/tests/cpp-empty-test/proj.android/jni/main.cpp b/tests/cpp-empty-test/proj.android/jni/main.cpp index feab560c09..4b0db09aa7 100644 --- a/tests/cpp-empty-test/proj.android/jni/main.cpp +++ b/tests/cpp-empty-test/proj.android/jni/main.cpp @@ -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(); } diff --git a/tests/cpp-tests/proj.android-studio/app/jni/main.cpp b/tests/cpp-tests/proj.android-studio/app/jni/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/tests/cpp-tests/proj.android-studio/app/jni/main.cpp +++ b/tests/cpp-tests/proj.android-studio/app/jni/main.cpp @@ -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(); } diff --git a/tests/cpp-tests/proj.android/jni/main.cpp b/tests/cpp-tests/proj.android/jni/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/tests/cpp-tests/proj.android/jni/main.cpp +++ b/tests/cpp-tests/proj.android/jni/main.cpp @@ -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(); } diff --git a/tests/game-controller-test/proj.android-studio/app/jni/main.cpp b/tests/game-controller-test/proj.android-studio/app/jni/main.cpp index feab560c09..4b0db09aa7 100644 --- a/tests/game-controller-test/proj.android-studio/app/jni/main.cpp +++ b/tests/game-controller-test/proj.android-studio/app/jni/main.cpp @@ -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(); } diff --git a/tests/game-controller-test/proj.android/jni/main.cpp b/tests/game-controller-test/proj.android/jni/main.cpp index feab560c09..4b0db09aa7 100644 --- a/tests/game-controller-test/proj.android/jni/main.cpp +++ b/tests/game-controller-test/proj.android/jni/main.cpp @@ -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(); } diff --git a/tests/js-tests/project/proj.android-studio/app/jni/main.cpp b/tests/js-tests/project/proj.android-studio/app/jni/main.cpp index baf5ca9810..2d9745860d 100644 --- a/tests/js-tests/project/proj.android-studio/app/jni/main.cpp +++ b/tests/js-tests/project/proj.android-studio/app/jni/main.cpp @@ -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; diff --git a/tests/js-tests/project/proj.android/jni/main.cpp b/tests/js-tests/project/proj.android/jni/main.cpp index baf5ca9810..2d9745860d 100644 --- a/tests/js-tests/project/proj.android/jni/main.cpp +++ b/tests/js-tests/project/proj.android/jni/main.cpp @@ -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; diff --git a/tests/lua-empty-test/project/proj.android-studio/app/jni/main.cpp b/tests/lua-empty-test/project/proj.android-studio/app/jni/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/tests/lua-empty-test/project/proj.android-studio/app/jni/main.cpp +++ b/tests/lua-empty-test/project/proj.android-studio/app/jni/main.cpp @@ -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(); } diff --git a/tests/lua-empty-test/project/proj.android/jni/main.cpp b/tests/lua-empty-test/project/proj.android/jni/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/tests/lua-empty-test/project/proj.android/jni/main.cpp +++ b/tests/lua-empty-test/project/proj.android/jni/main.cpp @@ -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(); } diff --git a/tests/lua-game-controller-test/project/proj.android-studio/app/jni/main.cpp b/tests/lua-game-controller-test/project/proj.android-studio/app/jni/main.cpp index 882c5632e7..8e8e384301 100644 --- a/tests/lua-game-controller-test/project/proj.android-studio/app/jni/main.cpp +++ b/tests/lua-game-controller-test/project/proj.android-studio/app/jni/main.cpp @@ -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(); } diff --git a/tests/lua-game-controller-test/project/proj.android/jni/main.cpp b/tests/lua-game-controller-test/project/proj.android/jni/main.cpp index 882c5632e7..8e8e384301 100644 --- a/tests/lua-game-controller-test/project/proj.android/jni/main.cpp +++ b/tests/lua-game-controller-test/project/proj.android/jni/main.cpp @@ -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(); } diff --git a/tests/lua-tests/project/proj.android-studio/app/jni/main.cpp b/tests/lua-tests/project/proj.android-studio/app/jni/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/tests/lua-tests/project/proj.android-studio/app/jni/main.cpp +++ b/tests/lua-tests/project/proj.android-studio/app/jni/main.cpp @@ -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(); } diff --git a/tests/lua-tests/project/proj.android/jni/main.cpp b/tests/lua-tests/project/proj.android/jni/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/tests/lua-tests/project/proj.android/jni/main.cpp +++ b/tests/lua-tests/project/proj.android/jni/main.cpp @@ -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(); } From e253237e6261bb8bec2185e11a909b35bdd44c35 Mon Sep 17 00:00:00 2001 From: Bin Zhang Date: Tue, 23 Jun 2015 18:18:02 +0800 Subject: [PATCH 21/22] Support package engine code on windows (for framework). --- tools/make-package/git-archive-all | 47 ++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/tools/make-package/git-archive-all b/tools/make-package/git-archive-all index 00968e3851..32b1c98260 100755 --- a/tools/make-package/git-archive-all +++ b/tools/make-package/git-archive-all @@ -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 From 5472928aaadc46664928e45ac86955a37c4ddaee Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 23 Jun 2015 18:54:18 +0800 Subject: [PATCH 22/22] add info into BlendFunc tests on canvas and tests data problem --- tests/js-tests/src/SpriteTest/SpriteTest.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/js-tests/src/SpriteTest/SpriteTest.js b/tests/js-tests/src/SpriteTest/SpriteTest.js index fc5ca5e63b..9ce1da7414 100644 --- a/tests/js-tests/src/SpriteTest/SpriteTest.js +++ b/tests/js-tests/src/SpriteTest/SpriteTest.js @@ -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]; @@ -5387,7 +5395,7 @@ var SpriteBlendFuncTest = SpriteTestDemo.extend({ //destSprite.setScale(0.8); destSprite.setPosition( 220 + i * 60, 355 - j * 60); // destSprite.setBlendFunc(srcFactors[j], destFactors[i]); - + this.addChild(destSprite,1); this.addChild(sourceSprite,2); }