diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id index a8e1f5ae28..834104dc3e 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -d5aad52713bc25f053afa48235e48aae9155f328 \ No newline at end of file +35abe9ed0238f007fc0b75f05c9e1a5a59d8be90 \ No newline at end of file diff --git a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp index 321d5c470c..5d298b81aa 100644 --- a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp +++ b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp @@ -63,7 +63,6 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V int actionCount = DICTOOL->getArrayCount_json(dic, "actionlist"); for (int i=0; iautorelease(); const rapidjson::Value &actionDic = DICTOOL->getDictionaryFromArray_json(dic, "actionlist", i); action->initWithDictionary(actionDic,root); actionList.pushBack(action); @@ -110,10 +109,17 @@ ActionObject* ActionManagerEx::playActionByName(const char* jsonName,const char* } return action; } - + void ActionManagerEx::releaseActions() { - _actionDic.clear(); + std::unordered_map>::iterator iter; + for (iter = _actionDic.begin(); iter != _actionDic.end(); iter++) + { + cocos2d::Vector objList = iter->second; + objList.clear(); + } + + _actionDic.clear(); } } \ No newline at end of file diff --git a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp index 7e19ea04dd..616dad40d3 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp @@ -40,7 +40,7 @@ namespace cocostudio Slider* slider = static_cast(widget); - bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, "barTextureScale9Enable"); + bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); slider->setScale9Enabled(barTextureScale9Enable); bool bt = DICTOOL->checkObjectExist_json(options, "barFileName"); float barLength = DICTOOL->getFloatValue_json(options, "length"); diff --git a/cocos/gui/UIButton.cpp b/cocos/gui/UIButton.cpp index bd31ade53e..9dc1ff3510 100644 --- a/cocos/gui/UIButton.cpp +++ b/cocos/gui/UIButton.cpp @@ -88,6 +88,7 @@ bool Button::init() { if (Widget::init()) { + setTouchEnabled(true); return true; } return false; diff --git a/cocos/gui/UICheckBox.cpp b/cocos/gui/UICheckBox.cpp index f88707d556..a02e0aa1e5 100644 --- a/cocos/gui/UICheckBox.cpp +++ b/cocos/gui/UICheckBox.cpp @@ -81,6 +81,7 @@ bool CheckBox::init() if (Widget::init()) { setSelectedState(false); + setTouchEnabled(true); return true; } return false; diff --git a/cocos/gui/UISlider.cpp b/cocos/gui/UISlider.cpp index 40f5810393..1fdc8524fb 100644 --- a/cocos/gui/UISlider.cpp +++ b/cocos/gui/UISlider.cpp @@ -82,6 +82,16 @@ Slider* Slider::create() return nullptr; } +bool Slider::init() +{ + if (Widget::init()) + { + setTouchEnabled(true); + return true; + } + return false; +} + void Slider::initRenderer() { _barRenderer = Sprite::create(); diff --git a/cocos/gui/UISlider.h b/cocos/gui/UISlider.h index b209139b42..9ceb50e849 100644 --- a/cocos/gui/UISlider.h +++ b/cocos/gui/UISlider.h @@ -195,6 +195,7 @@ public: virtual std::string getDescription() const override; protected: + virtual bool init() override; virtual void initRenderer() override; float getPercentWithBallPos(float location); void percentChangedEvent(); diff --git a/cocos/gui/UIText.cpp b/cocos/gui/UIText.cpp index 614f8dfcd3..429228935e 100644 --- a/cocos/gui/UIText.cpp +++ b/cocos/gui/UIText.cpp @@ -77,9 +77,6 @@ void Text::initRenderer() void Text::setText(const std::string& text) { - if (text.size()==0) - return; - _labelRenderer->setString(text); labelScaleChangedWithSize(); } diff --git a/cocos/gui/UITextField.cpp b/cocos/gui/UITextField.cpp index aedefea9ac..b07baf43f3 100644 --- a/cocos/gui/UITextField.cpp +++ b/cocos/gui/UITextField.cpp @@ -373,6 +373,16 @@ TextField* TextField::create() return nullptr; } +bool TextField::init() +{ + if (Widget::init()) + { + setTouchEnabled(true); + return true; + } + return false; +} + void TextField::onEnter() { Widget::onEnter(); @@ -387,7 +397,6 @@ void TextField::initRenderer() void TextField::setTouchSize(const Size &size) { -// _useTouchArea = true; _touchWidth = size.width; _touchHeight = size.height; } diff --git a/cocos/gui/UITextField.h b/cocos/gui/UITextField.h index 9c89a118a2..06cc3bcc60 100644 --- a/cocos/gui/UITextField.h +++ b/cocos/gui/UITextField.h @@ -159,7 +159,7 @@ public: void setTextHorizontalAlignment(TextHAlignment alignment); void setTextVerticalAlignment(TextVAlignment alignment); protected: - // event + virtual bool init() override; virtual void initRenderer() override; void attachWithIMEEvent(); void detachWithIMEEvent(); diff --git a/tests/Android.mk b/tests/Android.mk index 8bd6505386..befb3222f1 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -99,8 +99,11 @@ Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor. Classes/ExtensionsTest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp \ Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp \ Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.cpp \ +Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp \ +Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.cpp \ Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomReader.cpp \ Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp \ +Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp \ Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp \ Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp \ Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp \ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b6dc3d4f41..3037e8fabd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -113,8 +113,11 @@ set(SAMPLE_SRC Classes/ExtensionsTest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.cpp + Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp + Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.cpp Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomReader.cpp Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp + Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp Classes/NewRendererTest/NewRendererTest.cpp Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp diff --git a/tests/Classes/AppDelegate.cpp b/tests/Classes/AppDelegate.cpp index 0572386d9c..2a05af9b93 100644 --- a/tests/Classes/AppDelegate.cpp +++ b/tests/Classes/AppDelegate.cpp @@ -72,17 +72,17 @@ bool AppDelegate::applicationDidFinishLaunching() { auto resourceSize = Size(960, 640); searchPaths.push_back("hd"); - searchPaths.push_back("hd/scenetest"); - searchPaths.push_back("hd/scenetest/ArmatureComponentTest"); - searchPaths.push_back("hd/scenetest/AttributeComponentTest"); - searchPaths.push_back("hd/scenetest/BackgroundComponentTest"); - searchPaths.push_back("hd/scenetest/EffectComponentTest"); - searchPaths.push_back("hd/scenetest/LoadSceneEdtiorFileTest"); - searchPaths.push_back("hd/scenetest/ParticleComponentTest"); - searchPaths.push_back("hd/scenetest/SpriteComponentTest"); - searchPaths.push_back("hd/scenetest/TmxMapComponentTest"); - searchPaths.push_back("hd/scenetest/UIComponentTest"); - searchPaths.push_back("hd/scenetest/TriggerTest"); +// searchPaths.push_back("hd/scenetest"); +// searchPaths.push_back("hd/scenetest/ArmatureComponentTest"); +// searchPaths.push_back("hd/scenetest/AttributeComponentTest"); +// searchPaths.push_back("hd/scenetest/BackgroundComponentTest"); +// searchPaths.push_back("hd/scenetest/EffectComponentTest"); +// searchPaths.push_back("hd/scenetest/LoadSceneEdtiorFileTest"); +// searchPaths.push_back("hd/scenetest/ParticleComponentTest"); +// searchPaths.push_back("hd/scenetest/SpriteComponentTest"); +// searchPaths.push_back("hd/scenetest/TmxMapComponentTest"); +// searchPaths.push_back("hd/scenetest/UIComponentTest"); +// searchPaths.push_back("hd/scenetest/TriggerTest"); director->setContentScaleFactor(resourceSize.height/designSize.height); } else diff --git a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomGUIScene.cpp b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomGUIScene.cpp index b07b2031d4..4c89986d0b 100644 --- a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomGUIScene.cpp +++ b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomGUIScene.cpp @@ -3,6 +3,7 @@ #include "CustomGUIScene.h" #include "CocoStudioGUITest.h" #include "CustomTest/CustomImageTest/CustomImageTest.h" +#include "CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.h" enum @@ -27,6 +28,15 @@ g_guisTests[] = pScene->release(); } }, + { + "custom gui particle widget Test", + [](Ref* sender) + { + CustomParticleWidgetScene* pScene = new CustomParticleWidgetScene(); + pScene->runThisTest(); + pScene->release(); + } + }, }; static const int g_maxTests = sizeof(g_guisTests) / sizeof(g_guisTests[0]); @@ -53,8 +63,8 @@ void CustomGUITestMainLayer::onEnter() for (int i = 0; i < g_maxTests; ++i) { auto pItem = MenuItemFont::create(g_guisTests[i].name, g_guisTests[i].callback); - pItem->setPosition(Point(s.width / 2, s.height / 2)); -// pItem->setPosition(Point(s.width / 2, s.height - (i + 1) * LINE_SPACE)); +// pItem->setPosition(Point(s.width / 2, s.height / 2)); + pItem->setPosition(Point(s.width / 2, s.height - (i + 1) * LINE_SPACE)); _itemMenu->addChild(pItem, kItemTagBasic + i); } diff --git a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp index dd6b3ddad5..467df7b239 100644 --- a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp +++ b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp @@ -7,6 +7,8 @@ #include "../../CustomWidget/CustomReader.h" #include "cocostudio/CCSGUIReader.h" +USING_NS_CC; +USING_NS_CC_EXT; #pragma mark - #pragma mark CustomImageLayer diff --git a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.h b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.h index 1857444686..a9fdc25fe5 100644 --- a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.h +++ b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.h @@ -7,10 +7,7 @@ #include "extensions/cocos-ext.h" #include "../../../../testBasic.h" -USING_NS_CC; -USING_NS_CC_EXT; - -class CustomImageLayer : public Layer +class CustomImageLayer : public cocos2d::Layer { public: virtual void onEnter(); @@ -21,7 +18,7 @@ class CustomImageScene : public TestScene public: virtual void onEnter(); virtual void runThisTest(); - void BackCallback(Ref* pSender); + void BackCallback(cocos2d::Ref* pSender); }; #endif /* defined(__TestCpp__CustomUIScene__) */ diff --git a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp new file mode 100644 index 0000000000..2b328fdbda --- /dev/null +++ b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp @@ -0,0 +1,79 @@ +// +// CustomParticleWidgetTest.cpp +// CustomUI +// +// Created by cai wenzhi on 14-3-7. +// +// + +#include "CustomParticleWidgetTest.h" +#include "../../CustomGUIScene.h" +#include "../../CustomWidget/CustomParticleWidget.h" +#include "../../CustomWidget/CustomParticleWidgetReader.h" +#include "cocostudio/CCSGUIReader.h" + + +USING_NS_CC; +USING_NS_CC_EXT; +using namespace ui; +using namespace cocostudio; + +#pragma mark - +#pragma mark CustomParticleWidgetLayer +#pragma mark - + +void CustomParticleWidgetLayer::onEnter() +{ + CCLayer::onEnter(); + + GUIReader* guiReader = GUIReader::getInstance(); + guiReader->registerTypeAndCallBack("CustomParticleWidget", + &CustomParticleWidget::createInstance, + CustomParticleWidgetReader::getInstance(), + parseselector(CustomParticleWidgetReader::setProperties)); + + CustomParticleWidget* custom = CustomParticleWidget::create(); + custom->setParticlePlist("Particles/BoilingFoam.plist"); + + addChild(custom, 10, -1); +} + +#pragma mark - +#pragma mark CustomImageScene +#pragma mark - + +void CustomParticleWidgetScene::onEnter() +{ + CCScene::onEnter(); + + Layer* pLayer = new CustomParticleWidgetLayer(); + addChild(pLayer); + pLayer->release(); + + LabelTTF* label = LabelTTF::create("Back", "Arial", 20); + //#endif + MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(CustomParticleWidgetScene::BackCallback, this)); + + Menu* pMenu = Menu::create(pMenuItem, NULL); + + pMenu->setPosition( Point::ZERO ); + pMenuItem->setPosition( Point( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); + + addChild(pMenu, 1); +} + +void CustomParticleWidgetScene::runThisTest() +{ + Layer* pLayer = new CustomParticleWidgetLayer(); + addChild(pLayer); + pLayer->release(); + + CCDirector::getInstance()->replaceScene(this); +} + +void CustomParticleWidgetScene::BackCallback(Ref* pSender) +{ + CustomGUITestScene* pScene = new CustomGUITestScene(); + pScene->runThisTest(); + pScene->release(); +} diff --git a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.h b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.h new file mode 100644 index 0000000000..01e8c756e1 --- /dev/null +++ b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.h @@ -0,0 +1,30 @@ +// +// CustomParticleWidgetTest.h +// CustomUI +// +// Created by cai wenzhi on 14-3-7. +// +// + +#ifndef __CustomUI__CustomParticleWidgetTest__ +#define __CustomUI__CustomParticleWidgetTest__ + +#include "cocos2d.h" +#include "extensions/cocos-ext.h" +#include "../../../../testBasic.h" + +class CustomParticleWidgetLayer : public cocos2d::Layer +{ +public: + virtual void onEnter(); +}; + +class CustomParticleWidgetScene : public cocos2d::Scene +{ +public: + virtual void onEnter(); + virtual void runThisTest(); + void BackCallback(cocos2d::Ref* pSender); +}; + +#endif /* defined(__CustomUI__CustomParticleWidgetTest__) */ diff --git a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp index 0174d58963..ce6f253cea 100644 --- a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp +++ b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp @@ -2,6 +2,9 @@ #include "CustomImageView.h" +USING_NS_CC; +using namespace ui; + CustomImageView::CustomImageView() : _label(NULL) { diff --git a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.h b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.h index 0dc6916e4d..2e2630045e 100644 --- a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.h +++ b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.h @@ -4,10 +4,7 @@ #include "gui/CocosGUI.h" -USING_NS_CC; -using namespace cocos2d::ui; - -class CustomImageView : public ImageView +class CustomImageView : public cocos2d::ui::ImageView { public: @@ -15,7 +12,7 @@ public: ~CustomImageView(); static CustomImageView* create(); - static Ref* createInstance(); + static cocos2d::Ref* createInstance(); void setText(const std::string& text); const std::string& getText() const; @@ -25,7 +22,7 @@ protected: virtual void initRenderer() override; protected: - LabelTTF* _label; + cocos2d::LabelTTF* _label; }; #endif /* defined(__TestCpp__CustomImageView__) */ diff --git a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.cpp b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.cpp index 2ba3e2f300..d026cba12e 100644 --- a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.cpp +++ b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.cpp @@ -3,6 +3,11 @@ #include "CustomImageViewReader.h" #include "CustomImageView.h" +USING_NS_CC; +USING_NS_CC_EXT; +using namespace cocos2d::ui; +using namespace cocostudio; + static CustomImageViewReader* _instanceCustomImageViewReader = NULL; CustomImageViewReader::CustomImageViewReader() diff --git a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.h b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.h index 46ce391f4c..94f6773494 100644 --- a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.h +++ b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.h @@ -7,12 +7,7 @@ #include "cocostudio/DictionaryHelper.h" #include "gui/CocosGUI.h" -USING_NS_CC; -USING_NS_CC_EXT; -using namespace cocos2d::ui; -using namespace cocostudio; - -class CustomImageViewReader : public Ref +class CustomImageViewReader : public cocos2d::Ref { public: @@ -22,7 +17,7 @@ public: static CustomImageViewReader* getInstance(); static void purge(); - virtual void setProperties(const std::string& classType, Widget* widget, const rapidjson::Value& customOptions); + virtual void setProperties(const std::string& classType, cocos2d::ui::Widget* widget, const rapidjson::Value& customOptions); }; #endif /* defined(__TestCpp__CustomImageViewReader__) */ diff --git a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp new file mode 100644 index 0000000000..a37b6a1f03 --- /dev/null +++ b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp @@ -0,0 +1,97 @@ +// +// CustomParticleWidget.cpp +// CustomUI +// +// Created by cai wenzhi on 14-3-7. +// +// + +#include "CustomParticleWidget.h" + +USING_NS_CC; +using namespace ui; + +CustomParticleWidget::CustomParticleWidget() +: _emitter(NULL) +, _emitterPlist("") +{ + +} + +CustomParticleWidget::~CustomParticleWidget() +{ + +} + +Ref* CustomParticleWidget::createInstance() +{ + return create(); +} + +CustomParticleWidget* CustomParticleWidget::create() +{ + CustomParticleWidget* custom = new CustomParticleWidget(); + + if (custom && custom->init()) + { + custom->autorelease(); + return custom; + } + CC_SAFE_DELETE(custom); + return NULL; +} + +bool CustomParticleWidget::init() +{ + if (Widget::init()) + { + return true; + } + return false; +} + +void CustomParticleWidget::initRenderer() +{ + Widget::initRenderer(); +} + +void CustomParticleWidget::removeAllChildren() +{ + Widget::removeAllChildren(); +} + +void CustomParticleWidget::setParticlePlist(const char *plist) +{ + if (!_emitter) + { + _emitter = ParticleSystemQuad::create(plist); + + } + else + { + _emitter->removeFromParent(); + _emitter = ParticleSystemQuad::create(plist); + } + Node::addChild(_emitter , getZOrder() + 1, -1); + + _emitterPlist = plist; +} + +const char* CustomParticleWidget::getParticlePlist() const +{ + return _emitterPlist; +} + +void CustomParticleWidget::setParticlePosition(const Point &pos) +{ + _emitter->setPosition(pos); + + _emitterPostion = pos; +} + +const CCPoint& CustomParticleWidget::getParticlePosition() const +{ + return _emitterPostion; +} + + diff --git a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h new file mode 100644 index 0000000000..dee49860a8 --- /dev/null +++ b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h @@ -0,0 +1,43 @@ +// +// CustomParticleWidget.h +// CustomUI +// +// Created by cai wenzhi on 14-3-7. +// +// + +#ifndef __CustomUI__CustomParticleWidget__ +#define __CustomUI__CustomParticleWidget__ + +#include "gui/CocosGUI.h" + +class CustomParticleWidget : public cocos2d::ui::Widget +{ +public: + + CustomParticleWidget(); + ~CustomParticleWidget(); + + static CustomParticleWidget* create(); + static cocos2d::Ref* createInstance(); + + void setParticlePlist(const char* plist); + const char* getParticlePlist() const; + + void setParticlePosition(const cocos2d::Point& pos); + const cocos2d::Point& getParticlePosition() const; + +protected: + virtual bool init(); + virtual void initRenderer(); + + virtual void removeAllChildren(); + +protected: + cocos2d::ParticleSystem* _emitter; + const char* _emitterPlist; + cocos2d::Point _emitterPostion; + +}; + +#endif /* defined(__CustomUI__CustomParticleWidget__) */ diff --git a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.cpp b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.cpp new file mode 100644 index 0000000000..f070381ed4 --- /dev/null +++ b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.cpp @@ -0,0 +1,51 @@ +// +// CustomParticleWidgetReader.cpp +// CustomUI +// +// Created by cai wenzhi on 14-3-7. +// +// + +#include "CustomParticleWidgetReader.h" +#include "CustomParticleWidget.h" + +USING_NS_CC; +USING_NS_CC_EXT; +using namespace ui; +using namespace cocostudio; + +CustomParticleWidgetReader::CustomParticleWidgetReader() +{ + +} + +CustomParticleWidgetReader::~CustomParticleWidgetReader() +{ + +} + +static CustomParticleWidgetReader* _instanceCustomParticleWidgetReader = NULL; + +CustomParticleWidgetReader* CustomParticleWidgetReader::getInstance() +{ + if (!_instanceCustomParticleWidgetReader) + { + _instanceCustomParticleWidgetReader = new CustomParticleWidgetReader(); + } + return _instanceCustomParticleWidgetReader; +} + +void CustomParticleWidgetReader::setProperties(const std::string& classType, + Widget *widget, + const rapidjson::Value &customOptions) +{ + + CustomParticleWidget* custom = static_cast(widget); + + bool isExistParticlePlist = DICTOOL->checkObjectExist_json(customOptions, "ParticlePlist"); + if (isExistParticlePlist) + { + const char* ParticlePlist = DICTOOL->getStringValue_json(customOptions, "ParticlePlist"); + custom->setParticlePlist(ParticlePlist); + } +} diff --git a/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.h b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.h new file mode 100644 index 0000000000..04fa832189 --- /dev/null +++ b/tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.h @@ -0,0 +1,28 @@ +// +// CustomParticleWidgetReader.h +// CustomUI +// +// Created by cai wenzhi on 14-3-7. +// +// + +#ifndef __CustomUI__CustomParticleWidgetReader__ +#define __CustomUI__CustomParticleWidgetReader__ + +#include "extensions/cocos-ext.h" +#include "cocostudio/DictionaryHelper.h" +#include "gui/CocosGUI.h" + +class CustomParticleWidgetReader : public cocos2d::Ref +{ +public: + CustomParticleWidgetReader(); + ~CustomParticleWidgetReader(); + + static CustomParticleWidgetReader* getInstance(); + static void purge(); + + virtual void setProperties(const std::string& classType, cocos2d::ui::Widget* widget, const rapidjson::Value& customOptions); +}; + +#endif /* defined(__CustomUI__CustomParticleWidgetReader__) */ diff --git a/tests/proj.win32/TestCpp.vcxproj b/tests/proj.win32/TestCpp.vcxproj index 0cb837ab59..3b4c2cbc5b 100644 --- a/tests/proj.win32/TestCpp.vcxproj +++ b/tests/proj.win32/TestCpp.vcxproj @@ -154,8 +154,11 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\websockets\prebuilt\win32\*.*" "$(OutDi + + + @@ -328,8 +331,11 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\websockets\prebuilt\win32\*.*" "$(OutDi + + + diff --git a/tests/proj.win32/TestCpp.vcxproj.filters b/tests/proj.win32/TestCpp.vcxproj.filters index 44339ae7c8..8d21cda714 100644 --- a/tests/proj.win32/TestCpp.vcxproj.filters +++ b/tests/proj.win32/TestCpp.vcxproj.filters @@ -322,6 +322,9 @@ {8bc33078-56ce-48a6-85fd-b9d67db67c13} + + {f2e15a07-0d4e-407f-b4dc-d7692afe64a4} + @@ -817,6 +820,15 @@ Classes\ExtensionsTest\CocoStudioGUITest\UIRichTextTest + + Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget + + + Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget + + + Classes\ExtensionsTest\CocoStudioGUITest\CustomTest\CustomParticleWidgetTest + @@ -1510,5 +1522,14 @@ Classes\ExtensionsTest\CocoStudioGUITest\UIRichTextTest + + Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget + + + Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget + + + Classes\ExtensionsTest\CocoStudioGUITest\CustomTest\CustomParticleWidgetTest + \ No newline at end of file