mirror of https://github.com/axmolengine/axmol.git
Merge pull request #5615 from nutty898/develop_nutty_modify_framework_for315
Develop nutty modify framework for315
This commit is contained in:
commit
bf8506d687
|
@ -1 +1 @@
|
||||||
d5aad52713bc25f053afa48235e48aae9155f328
|
35abe9ed0238f007fc0b75f05c9e1a5a59d8be90
|
|
@ -63,7 +63,6 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V
|
||||||
int actionCount = DICTOOL->getArrayCount_json(dic, "actionlist");
|
int actionCount = DICTOOL->getArrayCount_json(dic, "actionlist");
|
||||||
for (int i=0; i<actionCount; i++) {
|
for (int i=0; i<actionCount; i++) {
|
||||||
ActionObject* action = new ActionObject();
|
ActionObject* action = new ActionObject();
|
||||||
action->autorelease();
|
|
||||||
const rapidjson::Value &actionDic = DICTOOL->getDictionaryFromArray_json(dic, "actionlist", i);
|
const rapidjson::Value &actionDic = DICTOOL->getDictionaryFromArray_json(dic, "actionlist", i);
|
||||||
action->initWithDictionary(actionDic,root);
|
action->initWithDictionary(actionDic,root);
|
||||||
actionList.pushBack(action);
|
actionList.pushBack(action);
|
||||||
|
@ -113,6 +112,13 @@ ActionObject* ActionManagerEx::playActionByName(const char* jsonName,const char*
|
||||||
|
|
||||||
void ActionManagerEx::releaseActions()
|
void ActionManagerEx::releaseActions()
|
||||||
{
|
{
|
||||||
|
std::unordered_map<std::string, cocos2d::Vector<ActionObject*>>::iterator iter;
|
||||||
|
for (iter = _actionDic.begin(); iter != _actionDic.end(); iter++)
|
||||||
|
{
|
||||||
|
cocos2d::Vector<ActionObject*> objList = iter->second;
|
||||||
|
objList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
_actionDic.clear();
|
_actionDic.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace cocostudio
|
||||||
|
|
||||||
Slider* slider = static_cast<Slider*>(widget);
|
Slider* slider = static_cast<Slider*>(widget);
|
||||||
|
|
||||||
bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, "barTextureScale9Enable");
|
bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable");
|
||||||
slider->setScale9Enabled(barTextureScale9Enable);
|
slider->setScale9Enabled(barTextureScale9Enable);
|
||||||
bool bt = DICTOOL->checkObjectExist_json(options, "barFileName");
|
bool bt = DICTOOL->checkObjectExist_json(options, "barFileName");
|
||||||
float barLength = DICTOOL->getFloatValue_json(options, "length");
|
float barLength = DICTOOL->getFloatValue_json(options, "length");
|
||||||
|
|
|
@ -88,6 +88,7 @@ bool Button::init()
|
||||||
{
|
{
|
||||||
if (Widget::init())
|
if (Widget::init())
|
||||||
{
|
{
|
||||||
|
setTouchEnabled(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -81,6 +81,7 @@ bool CheckBox::init()
|
||||||
if (Widget::init())
|
if (Widget::init())
|
||||||
{
|
{
|
||||||
setSelectedState(false);
|
setSelectedState(false);
|
||||||
|
setTouchEnabled(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -82,6 +82,16 @@ Slider* Slider::create()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Slider::init()
|
||||||
|
{
|
||||||
|
if (Widget::init())
|
||||||
|
{
|
||||||
|
setTouchEnabled(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Slider::initRenderer()
|
void Slider::initRenderer()
|
||||||
{
|
{
|
||||||
_barRenderer = Sprite::create();
|
_barRenderer = Sprite::create();
|
||||||
|
|
|
@ -195,6 +195,7 @@ public:
|
||||||
virtual std::string getDescription() const override;
|
virtual std::string getDescription() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual bool init() override;
|
||||||
virtual void initRenderer() override;
|
virtual void initRenderer() override;
|
||||||
float getPercentWithBallPos(float location);
|
float getPercentWithBallPos(float location);
|
||||||
void percentChangedEvent();
|
void percentChangedEvent();
|
||||||
|
|
|
@ -77,9 +77,6 @@ void Text::initRenderer()
|
||||||
|
|
||||||
void Text::setText(const std::string& text)
|
void Text::setText(const std::string& text)
|
||||||
{
|
{
|
||||||
if (text.size()==0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_labelRenderer->setString(text);
|
_labelRenderer->setString(text);
|
||||||
labelScaleChangedWithSize();
|
labelScaleChangedWithSize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,6 +373,16 @@ TextField* TextField::create()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TextField::init()
|
||||||
|
{
|
||||||
|
if (Widget::init())
|
||||||
|
{
|
||||||
|
setTouchEnabled(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void TextField::onEnter()
|
void TextField::onEnter()
|
||||||
{
|
{
|
||||||
Widget::onEnter();
|
Widget::onEnter();
|
||||||
|
@ -387,7 +397,6 @@ void TextField::initRenderer()
|
||||||
|
|
||||||
void TextField::setTouchSize(const Size &size)
|
void TextField::setTouchSize(const Size &size)
|
||||||
{
|
{
|
||||||
// _useTouchArea = true;
|
|
||||||
_touchWidth = size.width;
|
_touchWidth = size.width;
|
||||||
_touchHeight = size.height;
|
_touchHeight = size.height;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ public:
|
||||||
void setTextHorizontalAlignment(TextHAlignment alignment);
|
void setTextHorizontalAlignment(TextHAlignment alignment);
|
||||||
void setTextVerticalAlignment(TextVAlignment alignment);
|
void setTextVerticalAlignment(TextVAlignment alignment);
|
||||||
protected:
|
protected:
|
||||||
// event
|
virtual bool init() override;
|
||||||
virtual void initRenderer() override;
|
virtual void initRenderer() override;
|
||||||
void attachWithIMEEvent();
|
void attachWithIMEEvent();
|
||||||
void detachWithIMEEvent();
|
void detachWithIMEEvent();
|
||||||
|
|
|
@ -99,8 +99,11 @@ Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.
|
||||||
Classes/ExtensionsTest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp \
|
Classes/ExtensionsTest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp \
|
||||||
Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp \
|
Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp \
|
||||||
Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.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/CustomWidget/CustomReader.cpp \
|
||||||
Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp \
|
Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp \
|
||||||
|
Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp \
|
||||||
Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp \
|
Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp \
|
||||||
Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp \
|
Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp \
|
||||||
Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp \
|
Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp \
|
||||||
|
|
|
@ -113,8 +113,11 @@ set(SAMPLE_SRC
|
||||||
Classes/ExtensionsTest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp
|
Classes/ExtensionsTest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp
|
||||||
Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp
|
Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp
|
||||||
Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.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/CustomWidget/CustomReader.cpp
|
||||||
Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp
|
Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp
|
||||||
|
Classes/ExtensionsTest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp
|
||||||
Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp
|
Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp
|
||||||
Classes/NewRendererTest/NewRendererTest.cpp
|
Classes/NewRendererTest/NewRendererTest.cpp
|
||||||
Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp
|
Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp
|
||||||
|
|
|
@ -72,17 +72,17 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
{
|
{
|
||||||
auto resourceSize = Size(960, 640);
|
auto resourceSize = Size(960, 640);
|
||||||
searchPaths.push_back("hd");
|
searchPaths.push_back("hd");
|
||||||
searchPaths.push_back("hd/scenetest");
|
// searchPaths.push_back("hd/scenetest");
|
||||||
searchPaths.push_back("hd/scenetest/ArmatureComponentTest");
|
// searchPaths.push_back("hd/scenetest/ArmatureComponentTest");
|
||||||
searchPaths.push_back("hd/scenetest/AttributeComponentTest");
|
// searchPaths.push_back("hd/scenetest/AttributeComponentTest");
|
||||||
searchPaths.push_back("hd/scenetest/BackgroundComponentTest");
|
// searchPaths.push_back("hd/scenetest/BackgroundComponentTest");
|
||||||
searchPaths.push_back("hd/scenetest/EffectComponentTest");
|
// searchPaths.push_back("hd/scenetest/EffectComponentTest");
|
||||||
searchPaths.push_back("hd/scenetest/LoadSceneEdtiorFileTest");
|
// searchPaths.push_back("hd/scenetest/LoadSceneEdtiorFileTest");
|
||||||
searchPaths.push_back("hd/scenetest/ParticleComponentTest");
|
// searchPaths.push_back("hd/scenetest/ParticleComponentTest");
|
||||||
searchPaths.push_back("hd/scenetest/SpriteComponentTest");
|
// searchPaths.push_back("hd/scenetest/SpriteComponentTest");
|
||||||
searchPaths.push_back("hd/scenetest/TmxMapComponentTest");
|
// searchPaths.push_back("hd/scenetest/TmxMapComponentTest");
|
||||||
searchPaths.push_back("hd/scenetest/UIComponentTest");
|
// searchPaths.push_back("hd/scenetest/UIComponentTest");
|
||||||
searchPaths.push_back("hd/scenetest/TriggerTest");
|
// searchPaths.push_back("hd/scenetest/TriggerTest");
|
||||||
director->setContentScaleFactor(resourceSize.height/designSize.height);
|
director->setContentScaleFactor(resourceSize.height/designSize.height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "CustomGUIScene.h"
|
#include "CustomGUIScene.h"
|
||||||
#include "CocoStudioGUITest.h"
|
#include "CocoStudioGUITest.h"
|
||||||
#include "CustomTest/CustomImageTest/CustomImageTest.h"
|
#include "CustomTest/CustomImageTest/CustomImageTest.h"
|
||||||
|
#include "CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.h"
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -27,6 +28,15 @@ g_guisTests[] =
|
||||||
pScene->release();
|
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]);
|
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)
|
for (int i = 0; i < g_maxTests; ++i)
|
||||||
{
|
{
|
||||||
auto pItem = MenuItemFont::create(g_guisTests[i].name, g_guisTests[i].callback);
|
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 / 2));
|
||||||
// pItem->setPosition(Point(s.width / 2, s.height - (i + 1) * LINE_SPACE));
|
pItem->setPosition(Point(s.width / 2, s.height - (i + 1) * LINE_SPACE));
|
||||||
_itemMenu->addChild(pItem, kItemTagBasic + i);
|
_itemMenu->addChild(pItem, kItemTagBasic + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include "../../CustomWidget/CustomReader.h"
|
#include "../../CustomWidget/CustomReader.h"
|
||||||
#include "cocostudio/CCSGUIReader.h"
|
#include "cocostudio/CCSGUIReader.h"
|
||||||
|
|
||||||
|
USING_NS_CC;
|
||||||
|
USING_NS_CC_EXT;
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark CustomImageLayer
|
#pragma mark CustomImageLayer
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
#include "extensions/cocos-ext.h"
|
#include "extensions/cocos-ext.h"
|
||||||
#include "../../../../testBasic.h"
|
#include "../../../../testBasic.h"
|
||||||
|
|
||||||
USING_NS_CC;
|
class CustomImageLayer : public cocos2d::Layer
|
||||||
USING_NS_CC_EXT;
|
|
||||||
|
|
||||||
class CustomImageLayer : public Layer
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void onEnter();
|
virtual void onEnter();
|
||||||
|
@ -21,7 +18,7 @@ class CustomImageScene : public TestScene
|
||||||
public:
|
public:
|
||||||
virtual void onEnter();
|
virtual void onEnter();
|
||||||
virtual void runThisTest();
|
virtual void runThisTest();
|
||||||
void BackCallback(Ref* pSender);
|
void BackCallback(cocos2d::Ref* pSender);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__TestCpp__CustomUIScene__) */
|
#endif /* defined(__TestCpp__CustomUIScene__) */
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
|
@ -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__) */
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
#include "CustomImageView.h"
|
#include "CustomImageView.h"
|
||||||
|
|
||||||
|
USING_NS_CC;
|
||||||
|
using namespace ui;
|
||||||
|
|
||||||
CustomImageView::CustomImageView()
|
CustomImageView::CustomImageView()
|
||||||
: _label(NULL)
|
: _label(NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,10 +4,7 @@
|
||||||
|
|
||||||
#include "gui/CocosGUI.h"
|
#include "gui/CocosGUI.h"
|
||||||
|
|
||||||
USING_NS_CC;
|
class CustomImageView : public cocos2d::ui::ImageView
|
||||||
using namespace cocos2d::ui;
|
|
||||||
|
|
||||||
class CustomImageView : public ImageView
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -15,7 +12,7 @@ public:
|
||||||
~CustomImageView();
|
~CustomImageView();
|
||||||
|
|
||||||
static CustomImageView* create();
|
static CustomImageView* create();
|
||||||
static Ref* createInstance();
|
static cocos2d::Ref* createInstance();
|
||||||
|
|
||||||
void setText(const std::string& text);
|
void setText(const std::string& text);
|
||||||
const std::string& getText() const;
|
const std::string& getText() const;
|
||||||
|
@ -25,7 +22,7 @@ protected:
|
||||||
virtual void initRenderer() override;
|
virtual void initRenderer() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LabelTTF* _label;
|
cocos2d::LabelTTF* _label;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__TestCpp__CustomImageView__) */
|
#endif /* defined(__TestCpp__CustomImageView__) */
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
#include "CustomImageViewReader.h"
|
#include "CustomImageViewReader.h"
|
||||||
#include "CustomImageView.h"
|
#include "CustomImageView.h"
|
||||||
|
|
||||||
|
USING_NS_CC;
|
||||||
|
USING_NS_CC_EXT;
|
||||||
|
using namespace cocos2d::ui;
|
||||||
|
using namespace cocostudio;
|
||||||
|
|
||||||
static CustomImageViewReader* _instanceCustomImageViewReader = NULL;
|
static CustomImageViewReader* _instanceCustomImageViewReader = NULL;
|
||||||
|
|
||||||
CustomImageViewReader::CustomImageViewReader()
|
CustomImageViewReader::CustomImageViewReader()
|
||||||
|
|
|
@ -7,12 +7,7 @@
|
||||||
#include "cocostudio/DictionaryHelper.h"
|
#include "cocostudio/DictionaryHelper.h"
|
||||||
#include "gui/CocosGUI.h"
|
#include "gui/CocosGUI.h"
|
||||||
|
|
||||||
USING_NS_CC;
|
class CustomImageViewReader : public cocos2d::Ref
|
||||||
USING_NS_CC_EXT;
|
|
||||||
using namespace cocos2d::ui;
|
|
||||||
using namespace cocostudio;
|
|
||||||
|
|
||||||
class CustomImageViewReader : public Ref
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -22,7 +17,7 @@ public:
|
||||||
static CustomImageViewReader* getInstance();
|
static CustomImageViewReader* getInstance();
|
||||||
static void purge();
|
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__) */
|
#endif /* defined(__TestCpp__CustomImageViewReader__) */
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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__) */
|
|
@ -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<CustomParticleWidget*>(widget);
|
||||||
|
|
||||||
|
bool isExistParticlePlist = DICTOOL->checkObjectExist_json(customOptions, "ParticlePlist");
|
||||||
|
if (isExistParticlePlist)
|
||||||
|
{
|
||||||
|
const char* ParticlePlist = DICTOOL->getStringValue_json(customOptions, "ParticlePlist");
|
||||||
|
custom->setParticlePlist(ParticlePlist);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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__) */
|
|
@ -154,8 +154,11 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\websockets\prebuilt\win32\*.*" "$(OutDi
|
||||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CocoStudioGUITest.cpp" />
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CocoStudioGUITest.cpp" />
|
||||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomGUIScene.cpp" />
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomGUIScene.cpp" />
|
||||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomTest\CustomImageTest\CustomImageTest.cpp" />
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomTest\CustomImageTest\CustomImageTest.cpp" />
|
||||||
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomTest\CustomParticleWidgetTest\CustomParticleWidgetTest.cpp" />
|
||||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomImageView.cpp" />
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomImageView.cpp" />
|
||||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomImageViewReader.cpp" />
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomImageViewReader.cpp" />
|
||||||
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomParticleWidget.cpp" />
|
||||||
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomParticleWidgetReader.cpp" />
|
||||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomReader.cpp" />
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomReader.cpp" />
|
||||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\GUIEditorTest.cpp" />
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\GUIEditorTest.cpp" />
|
||||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest\UIButtonTest.cpp" />
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest\UIButtonTest.cpp" />
|
||||||
|
@ -328,8 +331,11 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\websockets\prebuilt\win32\*.*" "$(OutDi
|
||||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CocoStudioGUITest.h" />
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CocoStudioGUITest.h" />
|
||||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomGUIScene.h" />
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomGUIScene.h" />
|
||||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomTest\CustomImageTest\CustomImageTest.h" />
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomTest\CustomImageTest\CustomImageTest.h" />
|
||||||
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomTest\CustomParticleWidgetTest\CustomParticleWidgetTest.h" />
|
||||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomImageView.h" />
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomImageView.h" />
|
||||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomImageViewReader.h" />
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomImageViewReader.h" />
|
||||||
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomParticleWidget.h" />
|
||||||
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomParticleWidgetReader.h" />
|
||||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomReader.h" />
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomReader.h" />
|
||||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\GUIEditorTest.h" />
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\GUIEditorTest.h" />
|
||||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest\UIButtonTest.h" />
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest\UIButtonTest.h" />
|
||||||
|
|
|
@ -322,6 +322,9 @@
|
||||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UIRichTextTest">
|
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UIRichTextTest">
|
||||||
<UniqueIdentifier>{8bc33078-56ce-48a6-85fd-b9d67db67c13}</UniqueIdentifier>
|
<UniqueIdentifier>{8bc33078-56ce-48a6-85fd-b9d67db67c13}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\CustomTest\CustomParticleWidgetTest">
|
||||||
|
<UniqueIdentifier>{f2e15a07-0d4e-407f-b4dc-d7692afe64a4}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="main.cpp">
|
<ClCompile Include="main.cpp">
|
||||||
|
@ -817,6 +820,15 @@
|
||||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIRichTextTest\UIRichTextTest.cpp">
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIRichTextTest\UIRichTextTest.cpp">
|
||||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIRichTextTest</Filter>
|
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIRichTextTest</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomParticleWidget.cpp">
|
||||||
|
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomParticleWidgetReader.cpp">
|
||||||
|
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomTest\CustomParticleWidgetTest\CustomParticleWidgetTest.cpp">
|
||||||
|
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\CustomTest\CustomParticleWidgetTest</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="main.h">
|
<ClInclude Include="main.h">
|
||||||
|
@ -1510,5 +1522,14 @@
|
||||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIRichTextTest\UIRichTextTest.h">
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIRichTextTest\UIRichTextTest.h">
|
||||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIRichTextTest</Filter>
|
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIRichTextTest</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomParticleWidget.h">
|
||||||
|
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget\CustomParticleWidgetReader.h">
|
||||||
|
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\CustomWidget</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CustomTest\CustomParticleWidgetTest\CustomParticleWidgetTest.h">
|
||||||
|
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\CustomTest\CustomParticleWidgetTest</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue