Merge branch 'develop' into newRenderer

This commit is contained in:
Nite Luo 2013-11-19 11:08:26 -08:00
commit a3725c2394
21 changed files with 671 additions and 365 deletions

View File

@ -30,6 +30,7 @@ cocos2d-x-3.0alpha1 Nov.19 2013
[FIX] EventListner: cann't be removed sometimes
[FIX] UserDefault: didn't set data size when parsing XML using TinyXML
[FIX] Webp test crashed
[FIX] CCHttpClient: The subthread of CCHttpClient interrupts main thread if timeout signal comes.
[NEW] Arm64 support.
[NEW] Added Mouse Support For Desktop Platforms.
[NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc.

View File

@ -48,6 +48,14 @@ NS_CC_BEGIN
// Layer
Layer::Layer()
: _touchEnabled(false)
, _accelerometerEnabled(false)
, _keyboardEnabled(false)
, _touchMode(Touch::DispatchMode::ALL_AT_ONCE)
, _swallowsTouches(true)
, _touchListener(nullptr)
, _keyboardListener(nullptr)
, _accelerationListener(nullptr)
{
_ignoreAnchorPointForPosition = true;
setAnchorPoint(Point(0.5f, 0.5f));
@ -87,6 +95,343 @@ Layer *Layer::create()
}
}
/// Touch and Accelerometer related
void Layer::_addTouchListener()
{
if (_touchListener != nullptr)
return;
if( _touchMode == Touch::DispatchMode::ALL_AT_ONCE )
{
// Register Touch Event
auto listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesBegan = [=](const std::vector<Touch*>& touches, Event* event){
if (kScriptTypeNone != _scriptType)
{
TouchesScriptData data(EventTouch::EventCode::BEGAN, this, touches);
ScriptEvent event(kTouchesEvent, &data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
return;
}
CC_UNUSED_PARAM(touches);
CC_UNUSED_PARAM(event);
};
listener->onTouchesMoved = [=](const std::vector<Touch*>& touches, Event* event){
if (kScriptTypeNone != _scriptType)
{
TouchesScriptData data(EventTouch::EventCode::MOVED, this, touches);
ScriptEvent event(kTouchesEvent, &data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
return;
}
CC_UNUSED_PARAM(touches);
CC_UNUSED_PARAM(event);
};
listener->onTouchesEnded = [=](const std::vector<Touch*>& touches, Event* event){
if (kScriptTypeNone != _scriptType)
{
TouchesScriptData data(EventTouch::EventCode::ENDED, this, touches);
ScriptEvent event(kTouchesEvent, &data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
return;
}
CC_UNUSED_PARAM(touches);
CC_UNUSED_PARAM(event);
};
listener->onTouchesCancelled = [=](const std::vector<Touch*>& touches, Event* event){
if (kScriptTypeNone != _scriptType)
{
TouchesScriptData data(EventTouch::EventCode::CANCELLED, this, touches);
ScriptEvent event(kTouchesEvent, &data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
return;
}
CC_UNUSED_PARAM(touches);
CC_UNUSED_PARAM(event);
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
_touchListener = listener;
}
else
{
// Register Touch Event
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(_swallowsTouches);
listener->onTouchBegan = [=](Touch* touch, Event* event){
if (kScriptTypeNone != _scriptType)
{
TouchScriptData data(EventTouch::EventCode::BEGAN, this, touch);
ScriptEvent event(kTouchEvent, &data);
if(ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event))
return true;
else
return false;
}
return false;
};
listener->onTouchMoved = [=](Touch* touch, Event* event){
if (kScriptTypeNone != _scriptType)
{
TouchScriptData data(EventTouch::EventCode::MOVED, this, touch);
ScriptEvent event(kTouchEvent, &data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}
};
listener->onTouchEnded = [=](Touch* touch, Event* event){
if (kScriptTypeNone != _scriptType)
{
TouchScriptData data(EventTouch::EventCode::ENDED, this, touch);
ScriptEvent event(kTouchEvent, &data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}
};
listener->onTouchCancelled = [=](Touch* touch, Event* event){
if (kScriptTypeNone != _scriptType)
{
TouchScriptData data(EventTouch::EventCode::CANCELLED, this, touch);
ScriptEvent event(kTouchEvent, &data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
_touchListener = listener;
}
}
/// isTouchEnabled getter
bool Layer::isTouchEnabled() const
{
return _touchEnabled;
}
/// isTouchEnabled setter
void Layer::setTouchEnabled(bool enabled)
{
if (_touchEnabled != enabled)
{
_touchEnabled = enabled;
if (enabled)
{
this->_addTouchListener();
}
else
{
_eventDispatcher->removeEventListener(_touchListener);
_touchListener = nullptr;
}
}
}
void Layer::setTouchMode(Touch::DispatchMode mode)
{
if(_touchMode != mode)
{
_touchMode = mode;
if( _touchEnabled)
{
_eventDispatcher->removeEventListener(_touchListener);
_touchListener = nullptr;
this->_addTouchListener();
}
}
}
void Layer::setSwallowsTouches(bool swallowsTouches)
{
if (_swallowsTouches != swallowsTouches)
{
_swallowsTouches = swallowsTouches;
if( _touchEnabled)
{
_eventDispatcher->removeEventListener(_touchListener);
_touchListener = nullptr;
this->_addTouchListener();
}
}
}
Touch::DispatchMode Layer::getTouchMode() const
{
return _touchMode;
}
bool Layer::isSwallowsTouches() const
{
return _swallowsTouches;
}
/// isAccelerometerEnabled getter
bool Layer::isAccelerometerEnabled() const
{
return _accelerometerEnabled;
}
/// isAccelerometerEnabled setter
void Layer::setAccelerometerEnabled(bool enabled)
{
if (enabled != _accelerometerEnabled)
{
_accelerometerEnabled = enabled;
Device::setAccelerometerEnabled(enabled);
if (_running)
{
_eventDispatcher->removeEventListener(_accelerationListener);
_accelerationListener = nullptr;
if (enabled)
{
//Not to use onAcceleration for avoid warn from deprecated api
_accelerationListener = EventListenerAcceleration::create([=](Acceleration* acc, Event* event){
CC_UNUSED_PARAM(acc);
if(kScriptTypeNone != _scriptType)
{
BasicScriptData data(this,(void*)acc);
ScriptEvent event(kAccelerometerEvent,&data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}
});
_eventDispatcher->addEventListenerWithSceneGraphPriority(_accelerationListener, this);
}
}
}
}
void Layer::setAccelerometerInterval(double interval) {
if (_accelerometerEnabled)
{
if (_running)
{
Device::setAccelerometerInterval(interval);
}
}
}
void Layer::onAcceleration(Acceleration* pAccelerationValue, Event* event)
{
CC_UNUSED_PARAM(pAccelerationValue);
if(kScriptTypeNone != _scriptType)
{
BasicScriptData data(this,(void*)pAccelerationValue);
ScriptEvent event(kAccelerometerEvent,&data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}
}
void Layer::onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event)
{
CC_UNUSED_PARAM(keyCode);
CC_UNUSED_PARAM(event);
}
void Layer::onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event)
{
CC_UNUSED_PARAM(event);
if(kScriptTypeNone != _scriptType)
{
KeypadScriptData data(keyCode, this);
ScriptEvent event(kKeypadEvent,&data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}
}
/// isKeyboardEnabled getter
bool Layer::isKeyboardEnabled() const
{
return _keyboardEnabled;
}
/// isKeyboardEnabled setter
void Layer::setKeyboardEnabled(bool enabled)
{
if (enabled != _keyboardEnabled)
{
_keyboardEnabled = enabled;
_eventDispatcher->removeEventListener(_keyboardListener);
_keyboardListener = nullptr;
if (enabled)
{
auto listener = EventListenerKeyboard::create();
listener->onKeyPressed = [](EventKeyboard::KeyCode keyCode, Event* event){
CC_UNUSED_PARAM(keyCode);
CC_UNUSED_PARAM(event);
};
listener->onKeyReleased = [this](EventKeyboard::KeyCode keyCode, Event* event){
CC_UNUSED_PARAM(event);
if(kScriptTypeNone != _scriptType)
{
KeypadScriptData data(keyCode, this);
ScriptEvent event(kKeypadEvent,&data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
_keyboardListener = listener;
}
}
}
void Layer::setKeypadEnabled(bool enabled)
{
if (enabled != _keyboardEnabled)
{
_keyboardEnabled = enabled;
_eventDispatcher->removeEventListener(_keyboardListener);
_keyboardListener = nullptr;
if (enabled)
{
auto listener = EventListenerKeyboard::create();
listener->onKeyPressed = [](EventKeyboard::KeyCode keyCode, Event* event){
CC_UNUSED_PARAM(keyCode);
CC_UNUSED_PARAM(event);
};
listener->onKeyReleased = [this](EventKeyboard::KeyCode keyCode, Event* event){
CC_UNUSED_PARAM(event);
if(kScriptTypeNone != _scriptType)
{
KeypadScriptData data(keyCode, this);
ScriptEvent event(kKeypadEvent,&data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
_keyboardListener = listener;
}
}
}
// LayerRGBA
LayerRGBA::LayerRGBA()
: _displayedOpacity(255)

View File

@ -46,6 +46,10 @@ NS_CC_BEGIN
class TouchScriptHandlerEntry;
class EventListenerTouch;
class EventListenerKeyboard;
class EventListenerAcceleration;
//
// Layer
//
@ -82,10 +86,23 @@ public:
CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesEnded(Set *pTouches, Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesCancelled(Set *pTouches, Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
// Deprecated touch callbacks.There not have add CC_DEPRECATED_ATTRIBUTE because of menu still use these api
virtual bool onTouchBegan(Touch *touch, Event *event) {CC_UNUSED_PARAM(touch); CC_UNUSED_PARAM(event); return false;}
virtual void onTouchMoved(Touch *touch, Event *event) {CC_UNUSED_PARAM(touch); CC_UNUSED_PARAM(event);}
virtual void onTouchEnded(Touch *touch, Event *event) {CC_UNUSED_PARAM(touch); CC_UNUSED_PARAM(event);}
virtual void onTouchCancelled(Touch *touch, Event *event) {CC_UNUSED_PARAM(touch); CC_UNUSED_PARAM(event);}
// Deprecated touch callbacks.
CC_DEPRECATED_ATTRIBUTE virtual void onTouchesBegan(const std::vector<Touch*>& touches, Event *event) {CC_UNUSED_PARAM(touches); CC_UNUSED_PARAM(event);}
CC_DEPRECATED_ATTRIBUTE virtual void onTouchesMoved(const std::vector<Touch*>& touches, Event *event) {CC_UNUSED_PARAM(touches); CC_UNUSED_PARAM(event);}
CC_DEPRECATED_ATTRIBUTE virtual void onTouchesEnded(const std::vector<Touch*>& touches, Event *event) {CC_UNUSED_PARAM(touches); CC_UNUSED_PARAM(event);}
CC_DEPRECATED_ATTRIBUTE virtual void onTouchesCancelled(const std::vector<Touch*>&touches, Event *event) {CC_UNUSED_PARAM(touches); CC_UNUSED_PARAM(event);}
/** @deprecated Please override onAcceleration */
CC_DEPRECATED_ATTRIBUTE virtual void didAccelerate(Acceleration* accelerationValue) final {};
CC_DEPRECATED_ATTRIBUTE virtual void onAcceleration(Acceleration* acc, Event* event);
/** If isTouchEnabled, this method is called onEnter. Override it to change the
way Layer receives touch events.
( Default: TouchDispatcher::sharedDispatcher()->addStandardDelegate(this,0); )
@ -98,13 +115,48 @@ public:
*/
CC_DEPRECATED_ATTRIBUTE virtual void registerWithTouchDispatcher() final {};
/** whether or not it will receive Touch events.
You can enable / disable touch events with this property.
Only the touches of this node will be affected. This "method" is not propagated to it's children.
@since v0.8.1
*/
CC_DEPRECATED_ATTRIBUTE virtual bool isTouchEnabled() const;
CC_DEPRECATED_ATTRIBUTE virtual void setTouchEnabled(bool value);
CC_DEPRECATED_ATTRIBUTE virtual void setTouchMode(Touch::DispatchMode mode);
CC_DEPRECATED_ATTRIBUTE virtual Touch::DispatchMode getTouchMode() const;
/** swallowsTouches of the touch events. Default is true */
CC_DEPRECATED_ATTRIBUTE virtual void setSwallowsTouches(bool swallowsTouches);
CC_DEPRECATED_ATTRIBUTE virtual bool isSwallowsTouches() const;
/** whether or not it will receive Accelerometer events
You can enable / disable accelerometer events with this property.
@since v0.8.1
*/
CC_DEPRECATED_ATTRIBUTE virtual bool isAccelerometerEnabled() const;
CC_DEPRECATED_ATTRIBUTE virtual void setAccelerometerEnabled(bool value);
CC_DEPRECATED_ATTRIBUTE virtual void setAccelerometerInterval(double interval);
/** whether or not it will receive keyboard or keypad events
You can enable / disable accelerometer events with this property.
it's new in cocos2d-x
*/
CC_DEPRECATED_ATTRIBUTE virtual bool isKeyboardEnabled() const;
CC_DEPRECATED_ATTRIBUTE virtual void setKeyboardEnabled(bool value);
/** Please use onKeyPressed instead. */
virtual void keyPressed(int keyCode) final {};
/** Please use onKeyReleased instead. */
virtual void keyReleased(int keyCode) final {};
CC_DEPRECATED_ATTRIBUTE virtual void onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event);
CC_DEPRECATED_ATTRIBUTE virtual void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event);
CC_DEPRECATED_ATTRIBUTE virtual bool isKeypadEnabled() const final { return _keyboardEnabled; };
CC_DEPRECATED_ATTRIBUTE virtual void setKeypadEnabled(bool value);
/** @deprecated Please override onKeyReleased and check the keycode of KeyboardEvent::KeyCode::Menu(KEY_BACKSPACE) instead. */
CC_DEPRECATED_ATTRIBUTE virtual void keyBackClicked() final {};
@ -112,6 +164,23 @@ public:
//
// Overrides
//
protected:
CC_DEPRECATED_ATTRIBUTE void addTouchListener() { _addTouchListener();};
bool _touchEnabled;
bool _accelerometerEnabled;
bool _keyboardEnabled;
EventListener* _touchListener;
EventListenerKeyboard* _keyboardListener;
EventListenerAcceleration* _accelerationListener;
private:
//add the api for avoid use deprecated api
void _addTouchListener();
Touch::DispatchMode _touchMode;
bool _swallowsTouches;
};
#ifdef __apple__

View File

@ -328,22 +328,22 @@ void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Point
void ParticleSystemQuad::postStep()
{
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
// Option 1: Sub Data
// Option 1: Sub Data
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(_quads[0])*_totalParticles, _quads);
// Option 2: Data
// glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * particleCount, quads_, GL_DYNAMIC_DRAW);
// Option 3: Orphaning + glMapBuffer
// glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0])*_totalParticles, NULL, GL_STREAM_DRAW);
// void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
// memcpy(buf, _quads, sizeof(_quads[0])*_totalParticles);
// glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Option 2: Data
// glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * particleCount, quads_, GL_DYNAMIC_DRAW);
CHECK_GL_ERROR_DEBUG();
// Option 3: Orphaning + glMapBuffer
// glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0])*_totalParticles, NULL, GL_STREAM_DRAW);
// void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
// memcpy(buf, _quads, sizeof(_quads[0])*_totalParticles);
// glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, 0);
CHECK_GL_ERROR_DEBUG();
}
// overriding draw method

View File

@ -7,7 +7,7 @@
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(EngineRoot)cocos\2d;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath\include;$(EngineRoot)cocos\2d\platform\win32;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(EngineRoot)cocos\2d;$(EngineRoot)cocos\gui;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath\include;$(EngineRoot)cocos\2d\platform\win32;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_VARIADIC_MAX=10;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>

View File

@ -127,7 +127,11 @@ void ParticleSystemQuadLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pP
void ParticleSystemQuadLoader::onHandlePropTypeTexture(Node * pNode, Node * pParent, const char * pPropertyName, Texture2D * pTexture2D, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_TEXTURE) == 0) {
((ParticleSystemQuad *)pNode)->setTexture(pTexture2D);
static_cast<ParticleSystemQuad*>(pNode)->setTexture(pTexture2D);
if(pTexture2D)
{
static_cast<ParticleSystemQuad*>(pNode)->setBlendAdditive(true);
}
} else {
NodeLoader::onHandlePropTypeTexture(pNode, pParent, pPropertyName, pTexture2D, ccbReader);
}

View File

@ -95,13 +95,14 @@ ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char*
return NULL;
}
void ActionManagerEx::playActionByName(const char* jsonName,const char* actionName)
ActionObject* ActionManagerEx::playActionByName(const char* jsonName,const char* actionName)
{
ActionObject* action = getActionByName(jsonName,actionName);
if (action)
{
action->play();
}
return action;
}
void ActionManagerEx::releaseActions()

View File

@ -72,8 +72,10 @@ public:
* @param jsonName UI file name
*
* @param actionName action name in teh UIfile.
*
* @return ActionObject which named as the param name
*/
void playActionByName(const char* jsonName,const char* actionName);
ActionObject* playActionByName(const char* jsonName,const char* actionName);
/*init properties with json dictionay*/
void initWithDictionary(const char* jsonName,JsonDictionary* dic,cocos2d::Object* root);

View File

@ -41,15 +41,15 @@ ActionObject::ActionObject()
{
_actionNodeList = Array::create();
_actionNodeList->retain();
_pScheduler = new Scheduler();
Director::getInstance()->getScheduler()->scheduleUpdateForTarget(_pScheduler, 0, false);
_pScheduler = Director::getInstance()->getScheduler();
CC_SAFE_RETAIN(_pScheduler);
}
ActionObject::~ActionObject()
{
_actionNodeList->removeAllObjects();
_actionNodeList->release();
CC_SAFE_DELETE(_pScheduler);
CC_SAFE_RELEASE(_pScheduler);
}
void ActionObject::setName(const char* name)

View File

@ -315,7 +315,7 @@ void Bone::addChildBone(Bone *child)
_children->retain();
}
if (_children->getIndexOfObject(child) == UINT_MAX)
if (_children->getIndexOfObject(child) == CC_INVALID_INDEX)
{
_children->addObject(child);
child->setParentBone(this);
@ -324,7 +324,7 @@ void Bone::addChildBone(Bone *child)
void Bone::removeChildBone(Bone *bone, bool recursion)
{
if (_children && _children->getIndexOfObject(bone) != UINT_MAX )
if (_children && _children->getIndexOfObject(bone) != CC_INVALID_INDEX )
{
if(recursion)
{

View File

@ -475,7 +475,7 @@ float Tween::updateFrameData(float currentPercent)
* If frame tween easing equal to TWEEN_EASING_MAX, then it will not do tween.
*/
TweenType tweenType = (_frameTweenEasing != Linear) ? _frameTweenEasing : _tweenEasing;
if (tweenType != TWEEN_EASING_MAX && tweenType != Linear)
if (tweenType != TWEEN_EASING_MAX && tweenType != Linear && !_passLastFrame)
{
currentPercent = TweenFunction::tweenTo(0, 1, currentPercent, 1, tweenType);
}

View File

@ -33,239 +33,265 @@ using std::max;
namespace spine {
CCSkeleton* CCSkeleton::createWithData (SkeletonData* skeletonData, bool ownsSkeletonData) {
CCSkeleton* node = new CCSkeleton(skeletonData, ownsSkeletonData);
node->autorelease();
return node;
CCSkeleton* node = new CCSkeleton(skeletonData, ownsSkeletonData);
node->autorelease();
return node;
}
CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale) {
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlas, scale);
node->autorelease();
return node;
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlas, scale);
node->autorelease();
return node;
}
CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlasFile, scale);
node->autorelease();
return node;
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlasFile, scale);
node->autorelease();
return node;
}
void CCSkeleton::initialize () {
atlas = 0;
debugSlots = false;
debugBones = false;
timeScale = 1;
atlas = 0;
debugSlots = false;
debugBones = false;
timeScale = 1;
blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
setOpacityModifyRGB(true);
blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
setOpacityModifyRGB(true);
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
scheduleUpdate();
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
scheduleUpdate();
}
void CCSkeleton::setSkeletonData (SkeletonData *skeletonData, bool isOwnsSkeletonData) {
skeleton = Skeleton_create(skeletonData);
rootBone = skeleton->bones[0];
this->ownsSkeletonData = isOwnsSkeletonData;
skeleton = Skeleton_create(skeletonData);
rootBone = skeleton->bones[0];
this->ownsSkeletonData = isOwnsSkeletonData;
}
CCSkeleton::CCSkeleton () {
initialize();
initialize();
}
CCSkeleton::CCSkeleton (SkeletonData *skeletonData, bool isOwnsSkeletonData) {
initialize();
initialize();
setSkeletonData(skeletonData, isOwnsSkeletonData);
setSkeletonData(skeletonData, isOwnsSkeletonData);
}
CCSkeleton::CCSkeleton (const char* skeletonDataFile, Atlas* aAtlas, float scale) {
initialize();
initialize();
SkeletonJson* json = SkeletonJson_create(aAtlas);
json->scale = scale;
SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data.");
SkeletonJson_dispose(json);
SkeletonJson* json = SkeletonJson_create(aAtlas);
json->scale = scale;
SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data.");
SkeletonJson_dispose(json);
setSkeletonData(skeletonData, true);
setSkeletonData(skeletonData, true);
}
CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale) {
initialize();
initialize();
atlas = Atlas_readAtlasFile(atlasFile);
CCASSERT(atlas, "Error reading atlas file.");
atlas = Atlas_readAtlasFile(atlasFile);
CCASSERT(atlas, "Error reading atlas file.");
SkeletonJson* json = SkeletonJson_create(atlas);
json->scale = scale;
SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data file.");
SkeletonJson_dispose(json);
SkeletonJson* json = SkeletonJson_create(atlas);
json->scale = scale;
SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data file.");
SkeletonJson_dispose(json);
setSkeletonData(skeletonData, true);
setSkeletonData(skeletonData, true);
}
CCSkeleton::~CCSkeleton () {
if (ownsSkeletonData) SkeletonData_dispose(skeleton->data);
if (atlas) Atlas_dispose(atlas);
Skeleton_dispose(skeleton);
if (ownsSkeletonData) SkeletonData_dispose(skeleton->data);
if (atlas) Atlas_dispose(atlas);
Skeleton_dispose(skeleton);
}
void CCSkeleton::update (float deltaTime) {
Skeleton_update(skeleton, deltaTime * timeScale);
Skeleton_update(skeleton, deltaTime * timeScale);
}
void CCSkeleton::draw () {
CC_NODE_DRAW_SETUP();
void CCSkeleton::draw ()
{
CC_NODE_DRAW_SETUP();
GL::blendFunc(blendFunc.src, blendFunc.dst);
Color3B color = getColor();
skeleton->r = color.r / (float)255;
skeleton->g = color.g / (float)255;
skeleton->b = color.b / (float)255;
skeleton->a = getOpacity() / (float)255;
if (premultipliedAlpha)
{
skeleton->r *= skeleton->a;
skeleton->g *= skeleton->a;
skeleton->b *= skeleton->a;
}
GL::blendFunc(blendFunc.src, blendFunc.dst);
Color3B color = getColor();
skeleton->r = color.r / (float)255;
skeleton->g = color.g / (float)255;
skeleton->b = color.b / (float)255;
skeleton->a = getOpacity() / (float)255;
if (premultipliedAlpha) {
skeleton->r *= skeleton->a;
skeleton->g *= skeleton->a;
skeleton->b *= skeleton->a;
}
TextureAtlas* textureAtlas = 0;
V3F_C4B_T2F_Quad quad;
quad.tl.vertices.z = 0;
quad.tr.vertices.z = 0;
quad.bl.vertices.z = 0;
quad.br.vertices.z = 0;
for (int i = 0, n = skeleton->slotCount; i < n; i++)
{
Slot* slot = skeleton->slots[i];
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
TextureAtlas* regionTextureAtlas = getTextureAtlas(attachment);
if (regionTextureAtlas != textureAtlas)
{
if (textureAtlas)
{
if(textureAtlas->getTexture() && textureAtlas->getTexture()->hasPremultipliedAlpha())
{
GL::blendFunc(BlendFunc::ALPHA_PREMULTIPLIED.src, BlendFunc::ALPHA_PREMULTIPLIED.dst);
}
else
{
GL::blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED.src, BlendFunc::ALPHA_NON_PREMULTIPLIED.dst);
}
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
}
}
textureAtlas = regionTextureAtlas;
if (textureAtlas->getCapacity() == textureAtlas->getTotalQuads() &&
!textureAtlas->resizeCapacity(textureAtlas->getCapacity() * 2)) return;
RegionAttachment_updateQuad(attachment, slot, &quad, premultipliedAlpha);
textureAtlas->updateQuad(&quad, textureAtlas->getTotalQuads());
}
if (textureAtlas)
{
if(textureAtlas->getTexture() && textureAtlas->getTexture()->hasPremultipliedAlpha())
{
GL::blendFunc(BlendFunc::ALPHA_PREMULTIPLIED.src, BlendFunc::ALPHA_PREMULTIPLIED.dst);
}
else
{
GL::blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED.src, BlendFunc::ALPHA_NON_PREMULTIPLIED.dst);
}
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
}
TextureAtlas* textureAtlas = 0;
V3F_C4B_T2F_Quad quad;
quad.tl.vertices.z = 0;
quad.tr.vertices.z = 0;
quad.bl.vertices.z = 0;
quad.br.vertices.z = 0;
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
Slot* slot = skeleton->slots[i];
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
TextureAtlas* regionTextureAtlas = getTextureAtlas(attachment);
if (regionTextureAtlas != textureAtlas) {
if (textureAtlas) {
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
}
}
textureAtlas = regionTextureAtlas;
if (textureAtlas->getCapacity() == textureAtlas->getTotalQuads() &&
!textureAtlas->resizeCapacity(textureAtlas->getCapacity() * 2)) return;
RegionAttachment_updateQuad(attachment, slot, &quad, premultipliedAlpha);
textureAtlas->updateQuad(&quad, textureAtlas->getTotalQuads());
}
if (textureAtlas) {
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
}
if (debugSlots) {
// Slots.
DrawPrimitives::setDrawColor4B(0, 0, 255, 255);
glLineWidth(1);
Point points[4];
V3F_C4B_T2F_Quad tmpQuad;
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
Slot* slot = skeleton->slots[i];
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
RegionAttachment_updateQuad(attachment, slot, &tmpQuad);
points[0] = Point(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y);
points[1] = Point(tmpQuad.br.vertices.x, tmpQuad.br.vertices.y);
points[2] = Point(tmpQuad.tr.vertices.x, tmpQuad.tr.vertices.y);
points[3] = Point(tmpQuad.tl.vertices.x, tmpQuad.tl.vertices.y);
DrawPrimitives::drawPoly(points, 4, true);
}
}
if (debugBones) {
// Bone lengths.
glLineWidth(2);
DrawPrimitives::setDrawColor4B(255, 0, 0, 255);
for (int i = 0, n = skeleton->boneCount; i < n; i++) {
Bone *bone = skeleton->bones[i];
float x = bone->data->length * bone->m00 + bone->worldX;
float y = bone->data->length * bone->m10 + bone->worldY;
DrawPrimitives::drawLine(Point(bone->worldX, bone->worldY), Point(x, y));
}
// Bone origins.
DrawPrimitives::setPointSize(4);
DrawPrimitives::setDrawColor4B(0, 0, 255, 255); // Root bone is blue.
for (int i = 0, n = skeleton->boneCount; i < n; i++) {
Bone *bone = skeleton->bones[i];
DrawPrimitives::drawPoint(Point(bone->worldX, bone->worldY));
if (i == 0) DrawPrimitives::setDrawColor4B(0, 255, 0, 255);
}
}
if (debugSlots)
{
// Slots.
DrawPrimitives::setDrawColor4B(0, 0, 255, 255);
glLineWidth(1);
Point points[4];
V3F_C4B_T2F_Quad tmpQuad;
for (int i = 0, n = skeleton->slotCount; i < n; i++)
{
Slot* slot = skeleton->slots[i];
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
RegionAttachment_updateQuad(attachment, slot, &tmpQuad);
points[0] = Point(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y);
points[1] = Point(tmpQuad.br.vertices.x, tmpQuad.br.vertices.y);
points[2] = Point(tmpQuad.tr.vertices.x, tmpQuad.tr.vertices.y);
points[3] = Point(tmpQuad.tl.vertices.x, tmpQuad.tl.vertices.y);
DrawPrimitives::drawPoly(points, 4, true);
}
}
if (debugBones)
{
// Bone lengths.
glLineWidth(2);
DrawPrimitives::setDrawColor4B(255, 0, 0, 255);
for (int i = 0, n = skeleton->boneCount; i < n; i++)
{
Bone *bone = skeleton->bones[i];
float x = bone->data->length * bone->m00 + bone->worldX;
float y = bone->data->length * bone->m10 + bone->worldY;
DrawPrimitives::drawLine(Point(bone->worldX, bone->worldY), Point(x, y));
}
// Bone origins.
DrawPrimitives::setPointSize(4);
DrawPrimitives::setDrawColor4B(0, 0, 255, 255); // Root bone is blue.
for (int i = 0, n = skeleton->boneCount; i < n; i++)
{
Bone *bone = skeleton->bones[i];
DrawPrimitives::drawPoint(Point(bone->worldX, bone->worldY));
if (i == 0) DrawPrimitives::setDrawColor4B(0, 255, 0, 255);
}
}
}
TextureAtlas* CCSkeleton::getTextureAtlas (RegionAttachment* regionAttachment) const {
return (TextureAtlas*)((AtlasRegion*)regionAttachment->rendererObject)->page->rendererObject;
return (TextureAtlas*)((AtlasRegion*)regionAttachment->rendererObject)->page->rendererObject;
}
Rect CCSkeleton::getBoundingBox() const {
float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN;
float scaleX = getScaleX();
float scaleY = getScaleY();
float vertices[8];
for (int i = 0; i < skeleton->slotCount; ++i) {
Slot* slot = skeleton->slots[i];
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
RegionAttachment_computeVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices);
minX = min(minX, vertices[VERTEX_X1] * scaleX);
minY = min(minY, vertices[VERTEX_Y1] * scaleY);
maxX = max(maxX, vertices[VERTEX_X1] * scaleX);
maxY = max(maxY, vertices[VERTEX_Y1] * scaleY);
minX = min(minX, vertices[VERTEX_X4] * scaleX);
minY = min(minY, vertices[VERTEX_Y4] * scaleY);
maxX = max(maxX, vertices[VERTEX_X4] * scaleX);
maxY = max(maxY, vertices[VERTEX_Y4] * scaleY);
minX = min(minX, vertices[VERTEX_X2] * scaleX);
minY = min(minY, vertices[VERTEX_Y2] * scaleY);
maxX = max(maxX, vertices[VERTEX_X2] * scaleX);
maxY = max(maxY, vertices[VERTEX_Y2] * scaleY);
minX = min(minX, vertices[VERTEX_X3] * scaleX);
minY = min(minY, vertices[VERTEX_Y3] * scaleY);
maxX = max(maxX, vertices[VERTEX_X3] * scaleX);
maxY = max(maxY, vertices[VERTEX_Y3] * scaleY);
}
Point position = getPosition();
return Rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY);
float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN;
float scaleX = getScaleX();
float scaleY = getScaleY();
float vertices[8];
for (int i = 0; i < skeleton->slotCount; ++i) {
Slot* slot = skeleton->slots[i];
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
RegionAttachment_computeVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices);
minX = min(minX, vertices[VERTEX_X1] * scaleX);
minY = min(minY, vertices[VERTEX_Y1] * scaleY);
maxX = max(maxX, vertices[VERTEX_X1] * scaleX);
maxY = max(maxY, vertices[VERTEX_Y1] * scaleY);
minX = min(minX, vertices[VERTEX_X4] * scaleX);
minY = min(minY, vertices[VERTEX_Y4] * scaleY);
maxX = max(maxX, vertices[VERTEX_X4] * scaleX);
maxY = max(maxY, vertices[VERTEX_Y4] * scaleY);
minX = min(minX, vertices[VERTEX_X2] * scaleX);
minY = min(minY, vertices[VERTEX_Y2] * scaleY);
maxX = max(maxX, vertices[VERTEX_X2] * scaleX);
maxY = max(maxY, vertices[VERTEX_Y2] * scaleY);
minX = min(minX, vertices[VERTEX_X3] * scaleX);
minY = min(minY, vertices[VERTEX_Y3] * scaleY);
maxX = max(maxX, vertices[VERTEX_X3] * scaleX);
maxY = max(maxY, vertices[VERTEX_Y3] * scaleY);
}
Point position = getPosition();
return Rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY);
}
// --- Convenience methods for Skeleton_* functions.
void CCSkeleton::updateWorldTransform () {
Skeleton_updateWorldTransform(skeleton);
Skeleton_updateWorldTransform(skeleton);
}
void CCSkeleton::setToSetupPose () {
Skeleton_setToSetupPose(skeleton);
Skeleton_setToSetupPose(skeleton);
}
void CCSkeleton::setBonesToSetupPose () {
Skeleton_setBonesToSetupPose(skeleton);
Skeleton_setBonesToSetupPose(skeleton);
}
void CCSkeleton::setSlotsToSetupPose () {
Skeleton_setSlotsToSetupPose(skeleton);
Skeleton_setSlotsToSetupPose(skeleton);
}
Bone* CCSkeleton::findBone (const char* boneName) const {
return Skeleton_findBone(skeleton, boneName);
return Skeleton_findBone(skeleton, boneName);
}
Slot* CCSkeleton::findSlot (const char* slotName) const {
return Skeleton_findSlot(skeleton, slotName);
return Skeleton_findSlot(skeleton, slotName);
}
bool CCSkeleton::setSkin (const char* skinName) {
return Skeleton_setSkinByName(skeleton, skinName) ? true : false;
return Skeleton_setSkinByName(skeleton, skinName) ? true : false;
}
Attachment* CCSkeleton::getAttachment (const char* slotName, const char* attachmentName) const {
return Skeleton_getAttachmentForSlotName(skeleton, slotName, attachmentName);
return Skeleton_getAttachmentForSlotName(skeleton, slotName, attachmentName);
}
bool CCSkeleton::setAttachment (const char* slotName, const char* attachmentName) {
return Skeleton_setAttachment(skeleton, slotName, attachmentName) ? true : false;
return Skeleton_setAttachment(skeleton, slotName, attachmentName) ? true : false;
}
// --- BlendProtocol
@ -280,11 +306,11 @@ void CCSkeleton::setBlendFunc( const BlendFunc &aBlendFunc) {
}
void CCSkeleton::setOpacityModifyRGB (bool value) {
premultipliedAlpha = value;
premultipliedAlpha = value;
}
bool CCSkeleton::isOpacityModifyRGB () const {
return premultipliedAlpha;
return premultipliedAlpha;
}
} // namespace spine {

View File

@ -248,6 +248,10 @@ static bool configureCURL(CURL *handle)
}
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 0L);
// FIXED #3224: The subthread of CCHttpClient interrupts main thread if timeout comes.
// Document is here: http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTNOSIGNAL
curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L);
return true;
}

@ -1 +1 @@
Subproject commit 80567e2f54bf7c44375ce902e56d0ead37d362d0
Subproject commit 8f0159b894e47dd05ce454cf32f8d13bd4b39a63

View File

@ -1 +1 @@
5bc5339bd77792b57c97cebbe7dfd3b634038e38
3194d28204e71875735934ee3207961ec14e655a

View File

@ -60,6 +60,8 @@ bool SceneEditorTestLayer::init()
return bRet;
}
static ActionObject* actionObject = nullptr;
cocos2d::Node* SceneEditorTestLayer::createGameScene()
{
Node *pNode = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/FishJoy2.json");
@ -79,12 +81,16 @@ cocos2d::Node* SceneEditorTestLayer::createGameScene()
pNode->addChild(menuBack);
//ui action
ActionManagerEx::shareManager()->playActionByName("startMenu_1.json","Animation1");
actionObject = ActionManagerEx::shareManager()->playActionByName("startMenu_1.json","Animation1");
return pNode;
}
void SceneEditorTestLayer::toExtensionsMainLayer(cocos2d::Object *sender)
{
if (actionObject)
{
actionObject->stop();
}
ComAudio *pBackMusic = (ComAudio*)(_curNode->getComponent("CCBackgroundAudio"));
pBackMusic->stopBackgroundMusic();
ExtensionsTestScene *pScene = new ExtensionsTestScene();

View File

@ -67,22 +67,20 @@ MenuLayerMainMenu::MenuLayerMainMenu()
// Events
MenuItemFont::setFontName("Marker Felt");
auto item6 = MenuItemFont::create("Priority Test", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackPriorityTest, this));
// Bugs Item
auto item7 = MenuItemFont::create("Bugs", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackBugsTest, this));
auto item6 = MenuItemFont::create("Bugs", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackBugsTest, this));
// Font Item
auto item8 = MenuItemFont::create("Quit", CC_CALLBACK_1(MenuLayerMainMenu::onQuit, this));
auto item7= MenuItemFont::create("Quit", CC_CALLBACK_1(MenuLayerMainMenu::onQuit, this));
auto item9 = MenuItemFont::create("Remove menu item when moving", CC_CALLBACK_1(MenuLayerMainMenu::menuMovingCallback, this));
auto item8 = MenuItemFont::create("Remove menu item when moving", CC_CALLBACK_1(MenuLayerMainMenu::menuMovingCallback, this));
auto color_action = TintBy::create(0.5f, 0, -255, -255);
auto color_back = color_action->reverse();
auto seq = Sequence::create(color_action, color_back, NULL);
item8->runAction(RepeatForever::create(seq));
item7->runAction(RepeatForever::create(seq));
auto menu = Menu::create( item1, item2, item3, item4, item5, item6, item7, item8, item9, NULL);
auto menu = Menu::create( item1, item2, item3, item4, item5, item6, item7, item8, NULL);
menu->alignItemsVertically();
@ -172,14 +170,9 @@ void MenuLayerMainMenu::menuCallback2(Object* sender)
static_cast<LayerMultiplex*>(_parent)->switchTo(2);
}
void MenuLayerMainMenu::menuCallbackPriorityTest(Object* sender)
{
static_cast<LayerMultiplex*>(_parent)->switchTo(4);
}
void MenuLayerMainMenu::menuCallbackBugsTest(Object *pSender)
{
static_cast<LayerMultiplex*>(_parent)->switchTo(5);
static_cast<LayerMultiplex*>(_parent)->switchTo(4);
}
void MenuLayerMainMenu::onQuit(Object* sender)
@ -190,7 +183,7 @@ void MenuLayerMainMenu::onQuit(Object* sender)
void MenuLayerMainMenu::menuMovingCallback(Object *pSender)
{
static_cast<LayerMultiplex*>(_parent)->switchTo(6);
static_cast<LayerMultiplex*>(_parent)->switchTo(5);
}
//------------------------------------------------------------------
@ -461,64 +454,6 @@ void MenuLayer4::backCallback(Object* sender)
static_cast<LayerMultiplex*>(_parent)->switchTo(0);
}
MenuLayerPriorityTest::MenuLayerPriorityTest()
{
// Testing empty menu
_menu1 = Menu::create();
_menu2 = Menu::create();
// Menu 1
MenuItemFont::setFontName("Marker Felt");
MenuItemFont::setFontSize(18);
auto item1 = MenuItemFont::create("Return to Main Menu", CC_CALLBACK_1(MenuLayerPriorityTest::menuCallback, this));
auto item2 = MenuItemFont::create("Disable menu for 5 seconds", [&](Object *sender) {
_menu1->setEnabled(false);
auto wait = DelayTime::create(5);
auto enable = CallFunc::create( [&]() {
_menu1->setEnabled(true);
});
auto seq = Sequence::create(wait, enable, NULL);
_menu1->runAction(seq);
});
_menu1->addChild(item1);
_menu1->addChild(item2);
_menu1->alignItemsVerticallyWithPadding(2);
addChild(_menu1);
// Menu 2
_priority = true;
MenuItemFont::setFontSize(48);
item1 = MenuItemFont::create("Toggle priority", [&](Object *sender) {
if( _priority) {
// _menu2->setHandlerPriority(Menu::HANDLER_PRIORITY + 20);
_priority = false;
} else {
// _menu2->setHandlerPriority(Menu::HANDLER_PRIORITY - 20);
_priority = true;
}
});
item1->setColor(Color3B(0,0,255));
_menu2->addChild(item1);
addChild(_menu2);
}
MenuLayerPriorityTest::~MenuLayerPriorityTest()
{
}
void MenuLayerPriorityTest::menuCallback(Object* sender)
{
static_cast<LayerMultiplex*>(_parent)->switchTo(0);
// [[Director sharedDirector] poscene];
}
// BugsTest
BugsTest::BugsTest()
{
@ -621,11 +556,10 @@ void MenuTestScene::runThisTest()
auto layer2 = new MenuLayer2();
auto layer3 = new MenuLayer3();
auto layer4 = new MenuLayer4();
auto layer5 = new MenuLayerPriorityTest();
auto layer6 = new BugsTest();
auto layer7 = new RemoveMenuItemWhenMove();
auto layer5 = new BugsTest();
auto layer6 = new RemoveMenuItemWhenMove();
auto layer = LayerMultiplex::create(layer1, layer2, layer3, layer4, layer5, layer6, layer7, NULL);
auto layer = LayerMultiplex::create(layer1, layer2, layer3, layer4, layer5, layer6, NULL);
addChild(layer, 0);
layer1->release();
@ -634,7 +568,6 @@ void MenuTestScene::runThisTest()
layer4->release();
layer5->release();
layer6->release();
layer7->release();
Director::getInstance()->replaceScene(this);
}

View File

@ -79,19 +79,6 @@ public:
//CREATE_NODE(MenuLayer4);
};
class MenuLayerPriorityTest : public Layer
{
public:
MenuLayerPriorityTest();
~MenuLayerPriorityTest();
void menuCallback(Object* sender);
private:
Menu* _menu1;
Menu* _menu2;
bool _priority;
};
class BugsTest : public Layer
{
public:

View File

@ -151,8 +151,6 @@ public:
bool slice(PhysicsWorld& world, const PhysicsRayCastInfo& info, void* data);
void clipPoly(PhysicsShapePolygon* shape, Point normal, float distance);
bool onTouchBegan(Touch *touch, Event *event);
void onTouchMoved(Touch *touch, Event *event);
void onTouchEnded(Touch *touch, Event *event);
private:

View File

@ -98,42 +98,35 @@ local function MenuLayerMainMenu()
-- Testing issue #500
item5:setScale( 0.8 )
local function menuCallbackPriorityTest(pSender)
-- Events
cc.MenuItemFont:setFontName("Marker Felt")
local function menuCallbackBugsTest(pSender)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(4)
end
-- Events
cc.MenuItemFont:setFontName("Marker Felt")
local item6 = cc.MenuItemFont:create("Priority Test")
item6:registerScriptTapHandler(menuCallbackPriorityTest)
local function menuCallbackBugsTest(pSender)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(5)
end
-- Bugs Item
local item7 = cc.MenuItemFont:create("Bugs")
item7:registerScriptTapHandler(menuCallbackBugsTest)
local item6 = cc.MenuItemFont:create("Bugs")
item6:registerScriptTapHandler(menuCallbackBugsTest)
local function onQuit(sender)
cclog("onQuit item is clicked.")
end
-- Font Item
local item8 = cc.MenuItemFont:create("Quit")
item8:registerScriptTapHandler(onQuit)
local item7 = cc.MenuItemFont:create("Quit")
item7:registerScriptTapHandler(onQuit)
local function menuMovingCallback(pSender)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(6)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(5)
end
local item9 = cc.MenuItemFont:create("Remove menu item when moving")
item9:registerScriptTapHandler(menuMovingCallback)
local item8 = cc.MenuItemFont:create("Remove menu item when moving")
item8:registerScriptTapHandler(menuMovingCallback)
local color_action = cc.TintBy:create(0.5, 0, -255, -255)
local color_back = color_action:reverse()
local seq = cc.Sequence:create(color_action, color_back)
item8:runAction(cc.RepeatForever:create(seq))
item7:runAction(cc.RepeatForever:create(seq))
local menu = cc.Menu:create()
@ -145,7 +138,6 @@ local function MenuLayerMainMenu()
menu:addChild(item6)
menu:addChild(item7)
menu:addChild(item8)
menu:addChild(item9)
menu:alignItemsVertically()
@ -481,66 +473,6 @@ local function MenuLayer4()
return ret
end
local function MenuLayerPriorityTest()
local ret = cc.Layer:create()
local m_bPriority = false
-- Testing empty menu
local m_pMenu1 = cc.Menu:create()
local m_pMenu2 = cc.Menu:create()
local function menuCallback(tag, pSender)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0)
end
local function enableMenuCallback()
m_pMenu1:setEnabled(true)
end
local function disableMenuCallback(tag, pSender)
m_pMenu1:setEnabled(false)
local wait = cc.DelayTime:create(5)
local enable = cc.CallFunc:create(enableMenuCallback)
local seq = cc.Sequence:create(wait, enable)
m_pMenu1:runAction(seq)
end
local function togglePriorityCallback(tag, pSender)
if m_bPriority then
m_pMenu2:setHandlerPriority(cc.MENU_HANDLER_PRIORITY + 20)
m_bPriority = false
else
m_pMenu2:setHandlerPriority(cc.MENU_HANDLER_PRIORITY - 20)
m_bPriority = true
end
end
-- Menu 1
cc.MenuItemFont:setFontName("Marker Felt")
cc.MenuItemFont:setFontSize(18)
local item1 = cc.MenuItemFont:create("Return to Main Menu")
item1:registerScriptTapHandler(menuCallback)
local item2 = cc.MenuItemFont:create("Disable menu for 5 seconds")
item2:registerScriptTapHandler(disableMenuCallback)
m_pMenu1:addChild(item1)
m_pMenu1:addChild(item2)
m_pMenu1:alignItemsVerticallyWithPadding(20)
ret:addChild(m_pMenu1)
-- Menu 2
m_bPriority = true
cc.MenuItemFont:setFontSize(48)
item1 = cc.MenuItemFont:create("Toggle priority")
item2:registerScriptTapHandler(togglePriorityCallback)
item1:setColor(cc.c3b(0,0,255))
m_pMenu2:addChild(item1)
ret:addChild(m_pMenu2)
return ret
end
-- BugsTest
local function BugsTest()
local ret = cc.Layer:create()
@ -648,17 +580,15 @@ function MenuTestMain()
local pLayer3 = MenuLayer3()
local pLayer4 = MenuLayer4()
local pLayer5 = MenuLayerPriorityTest()
local pLayer6 = BugsTest()
local pLayer7 = RemoveMenuItemWhenMove()
local pLayer5 = BugsTest()
local pLayer6 = RemoveMenuItemWhenMove()
local layer = cc.LayerMultiplex:create(pLayer1,
pLayer2,
pLayer3,
pLayer4,
pLayer5,
pLayer6,
pLayer7)
pLayer6 )
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())

View File

@ -35,7 +35,7 @@ classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.*
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
# functions from all classes.
skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule],
skip = Node::[^setPosition$ setGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule],
Sprite::[getQuad getBlendFunc ^setPosition$ setBlendFunc],
SpriteBatchNode::[getBlendFunc setBlendFunc getDescendants],
MotionStreak::[getBlendFunc setBlendFunc draw update],