mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' into newRenderer
This commit is contained in:
commit
a3725c2394
|
@ -30,6 +30,7 @@ cocos2d-x-3.0alpha1 Nov.19 2013
|
||||||
[FIX] EventListner: cann't be removed sometimes
|
[FIX] EventListner: cann't be removed sometimes
|
||||||
[FIX] UserDefault: didn't set data size when parsing XML using TinyXML
|
[FIX] UserDefault: didn't set data size when parsing XML using TinyXML
|
||||||
[FIX] Webp test crashed
|
[FIX] Webp test crashed
|
||||||
|
[FIX] CCHttpClient: The subthread of CCHttpClient interrupts main thread if timeout signal comes.
|
||||||
[NEW] Arm64 support.
|
[NEW] Arm64 support.
|
||||||
[NEW] Added Mouse Support For Desktop Platforms.
|
[NEW] Added Mouse Support For Desktop Platforms.
|
||||||
[NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc.
|
[NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc.
|
||||||
|
|
|
@ -48,6 +48,14 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
// Layer
|
// Layer
|
||||||
Layer::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;
|
_ignoreAnchorPointForPosition = true;
|
||||||
setAnchorPoint(Point(0.5f, 0.5f));
|
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::LayerRGBA()
|
LayerRGBA::LayerRGBA()
|
||||||
: _displayedOpacity(255)
|
: _displayedOpacity(255)
|
||||||
|
|
|
@ -46,6 +46,10 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
class TouchScriptHandlerEntry;
|
class TouchScriptHandlerEntry;
|
||||||
|
|
||||||
|
class EventListenerTouch;
|
||||||
|
class EventListenerKeyboard;
|
||||||
|
class EventListenerAcceleration;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Layer
|
// 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 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);}
|
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 */
|
/** @deprecated Please override onAcceleration */
|
||||||
CC_DEPRECATED_ATTRIBUTE virtual void didAccelerate(Acceleration* accelerationValue) final {};
|
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
|
/** If isTouchEnabled, this method is called onEnter. Override it to change the
|
||||||
way Layer receives touch events.
|
way Layer receives touch events.
|
||||||
( Default: TouchDispatcher::sharedDispatcher()->addStandardDelegate(this,0); )
|
( Default: TouchDispatcher::sharedDispatcher()->addStandardDelegate(this,0); )
|
||||||
|
@ -98,13 +115,48 @@ public:
|
||||||
*/
|
*/
|
||||||
CC_DEPRECATED_ATTRIBUTE virtual void registerWithTouchDispatcher() final {};
|
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. */
|
/** Please use onKeyPressed instead. */
|
||||||
virtual void keyPressed(int keyCode) final {};
|
virtual void keyPressed(int keyCode) final {};
|
||||||
|
|
||||||
/** Please use onKeyReleased instead. */
|
/** Please use onKeyReleased instead. */
|
||||||
virtual void keyReleased(int keyCode) final {};
|
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. */
|
/** @deprecated Please override onKeyReleased and check the keycode of KeyboardEvent::KeyCode::Menu(KEY_BACKSPACE) instead. */
|
||||||
CC_DEPRECATED_ATTRIBUTE virtual void keyBackClicked() final {};
|
CC_DEPRECATED_ATTRIBUTE virtual void keyBackClicked() final {};
|
||||||
|
@ -112,6 +164,23 @@ public:
|
||||||
//
|
//
|
||||||
// Overrides
|
// 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__
|
#ifdef __apple__
|
||||||
|
|
|
@ -328,22 +328,22 @@ void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Point
|
||||||
void ParticleSystemQuad::postStep()
|
void ParticleSystemQuad::postStep()
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
|
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
|
||||||
|
|
||||||
// Option 1: Sub Data
|
// Option 1: Sub Data
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(_quads[0])*_totalParticles, _quads);
|
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
|
// overriding draw method
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<PropertyGroup />
|
<PropertyGroup />
|
||||||
<ItemDefinitionGroup>
|
<ItemDefinitionGroup>
|
||||||
<ClCompile>
|
<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>
|
<PreprocessorDefinitions>_VARIADIC_MAX=10;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
|
|
@ -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) {
|
void ParticleSystemQuadLoader::onHandlePropTypeTexture(Node * pNode, Node * pParent, const char * pPropertyName, Texture2D * pTexture2D, CCBReader * ccbReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_TEXTURE) == 0) {
|
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 {
|
} else {
|
||||||
NodeLoader::onHandlePropTypeTexture(pNode, pParent, pPropertyName, pTexture2D, ccbReader);
|
NodeLoader::onHandlePropTypeTexture(pNode, pParent, pPropertyName, pTexture2D, ccbReader);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,13 +95,14 @@ ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char*
|
||||||
return NULL;
|
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);
|
ActionObject* action = getActionByName(jsonName,actionName);
|
||||||
if (action)
|
if (action)
|
||||||
{
|
{
|
||||||
action->play();
|
action->play();
|
||||||
}
|
}
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionManagerEx::releaseActions()
|
void ActionManagerEx::releaseActions()
|
||||||
|
|
|
@ -72,8 +72,10 @@ public:
|
||||||
* @param jsonName UI file name
|
* @param jsonName UI file name
|
||||||
*
|
*
|
||||||
* @param actionName action name in teh UIfile.
|
* @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*/
|
/*init properties with json dictionay*/
|
||||||
void initWithDictionary(const char* jsonName,JsonDictionary* dic,cocos2d::Object* root);
|
void initWithDictionary(const char* jsonName,JsonDictionary* dic,cocos2d::Object* root);
|
||||||
|
|
|
@ -41,15 +41,15 @@ ActionObject::ActionObject()
|
||||||
{
|
{
|
||||||
_actionNodeList = Array::create();
|
_actionNodeList = Array::create();
|
||||||
_actionNodeList->retain();
|
_actionNodeList->retain();
|
||||||
_pScheduler = new Scheduler();
|
_pScheduler = Director::getInstance()->getScheduler();
|
||||||
Director::getInstance()->getScheduler()->scheduleUpdateForTarget(_pScheduler, 0, false);
|
CC_SAFE_RETAIN(_pScheduler);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionObject::~ActionObject()
|
ActionObject::~ActionObject()
|
||||||
{
|
{
|
||||||
_actionNodeList->removeAllObjects();
|
_actionNodeList->removeAllObjects();
|
||||||
_actionNodeList->release();
|
_actionNodeList->release();
|
||||||
CC_SAFE_DELETE(_pScheduler);
|
CC_SAFE_RELEASE(_pScheduler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionObject::setName(const char* name)
|
void ActionObject::setName(const char* name)
|
||||||
|
|
|
@ -315,7 +315,7 @@ void Bone::addChildBone(Bone *child)
|
||||||
_children->retain();
|
_children->retain();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_children->getIndexOfObject(child) == UINT_MAX)
|
if (_children->getIndexOfObject(child) == CC_INVALID_INDEX)
|
||||||
{
|
{
|
||||||
_children->addObject(child);
|
_children->addObject(child);
|
||||||
child->setParentBone(this);
|
child->setParentBone(this);
|
||||||
|
@ -324,7 +324,7 @@ void Bone::addChildBone(Bone *child)
|
||||||
|
|
||||||
void Bone::removeChildBone(Bone *bone, bool recursion)
|
void Bone::removeChildBone(Bone *bone, bool recursion)
|
||||||
{
|
{
|
||||||
if (_children && _children->getIndexOfObject(bone) != UINT_MAX )
|
if (_children && _children->getIndexOfObject(bone) != CC_INVALID_INDEX )
|
||||||
{
|
{
|
||||||
if(recursion)
|
if(recursion)
|
||||||
{
|
{
|
||||||
|
|
|
@ -475,7 +475,7 @@ float Tween::updateFrameData(float currentPercent)
|
||||||
* If frame tween easing equal to TWEEN_EASING_MAX, then it will not do tween.
|
* If frame tween easing equal to TWEEN_EASING_MAX, then it will not do tween.
|
||||||
*/
|
*/
|
||||||
TweenType tweenType = (_frameTweenEasing != Linear) ? _frameTweenEasing : _tweenEasing;
|
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);
|
currentPercent = TweenFunction::tweenTo(0, 1, currentPercent, 1, tweenType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,239 +33,265 @@ using std::max;
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
CCSkeleton* CCSkeleton::createWithData (SkeletonData* skeletonData, bool ownsSkeletonData) {
|
CCSkeleton* CCSkeleton::createWithData (SkeletonData* skeletonData, bool ownsSkeletonData) {
|
||||||
CCSkeleton* node = new CCSkeleton(skeletonData, ownsSkeletonData);
|
CCSkeleton* node = new CCSkeleton(skeletonData, ownsSkeletonData);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale) {
|
CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale) {
|
||||||
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlas, scale);
|
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlas, scale);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
||||||
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlasFile, scale);
|
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlasFile, scale);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::initialize () {
|
void CCSkeleton::initialize () {
|
||||||
atlas = 0;
|
atlas = 0;
|
||||||
debugSlots = false;
|
debugSlots = false;
|
||||||
debugBones = false;
|
debugBones = false;
|
||||||
timeScale = 1;
|
timeScale = 1;
|
||||||
|
|
||||||
blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
||||||
setOpacityModifyRGB(true);
|
setOpacityModifyRGB(true);
|
||||||
|
|
||||||
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setSkeletonData (SkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
void CCSkeleton::setSkeletonData (SkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
||||||
skeleton = Skeleton_create(skeletonData);
|
skeleton = Skeleton_create(skeletonData);
|
||||||
rootBone = skeleton->bones[0];
|
rootBone = skeleton->bones[0];
|
||||||
this->ownsSkeletonData = isOwnsSkeletonData;
|
this->ownsSkeletonData = isOwnsSkeletonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton () {
|
CCSkeleton::CCSkeleton () {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton (SkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
CCSkeleton::CCSkeleton (SkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
setSkeletonData(skeletonData, isOwnsSkeletonData);
|
setSkeletonData(skeletonData, isOwnsSkeletonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton (const char* skeletonDataFile, Atlas* aAtlas, float scale) {
|
CCSkeleton::CCSkeleton (const char* skeletonDataFile, Atlas* aAtlas, float scale) {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
SkeletonJson* json = SkeletonJson_create(aAtlas);
|
SkeletonJson* json = SkeletonJson_create(aAtlas);
|
||||||
json->scale = scale;
|
json->scale = scale;
|
||||||
SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
|
SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
|
||||||
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data.");
|
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data.");
|
||||||
SkeletonJson_dispose(json);
|
SkeletonJson_dispose(json);
|
||||||
|
|
||||||
setSkeletonData(skeletonData, true);
|
setSkeletonData(skeletonData, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
atlas = Atlas_readAtlasFile(atlasFile);
|
atlas = Atlas_readAtlasFile(atlasFile);
|
||||||
CCASSERT(atlas, "Error reading atlas file.");
|
CCASSERT(atlas, "Error reading atlas file.");
|
||||||
|
|
||||||
SkeletonJson* json = SkeletonJson_create(atlas);
|
SkeletonJson* json = SkeletonJson_create(atlas);
|
||||||
json->scale = scale;
|
json->scale = scale;
|
||||||
SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
|
SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
|
||||||
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data file.");
|
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data file.");
|
||||||
SkeletonJson_dispose(json);
|
SkeletonJson_dispose(json);
|
||||||
|
|
||||||
setSkeletonData(skeletonData, true);
|
setSkeletonData(skeletonData, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::~CCSkeleton () {
|
CCSkeleton::~CCSkeleton () {
|
||||||
if (ownsSkeletonData) SkeletonData_dispose(skeleton->data);
|
if (ownsSkeletonData) SkeletonData_dispose(skeleton->data);
|
||||||
if (atlas) Atlas_dispose(atlas);
|
if (atlas) Atlas_dispose(atlas);
|
||||||
Skeleton_dispose(skeleton);
|
Skeleton_dispose(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::update (float deltaTime) {
|
void CCSkeleton::update (float deltaTime) {
|
||||||
Skeleton_update(skeleton, deltaTime * timeScale);
|
Skeleton_update(skeleton, deltaTime * timeScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::draw () {
|
void CCSkeleton::draw ()
|
||||||
CC_NODE_DRAW_SETUP();
|
{
|
||||||
|
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);
|
TextureAtlas* textureAtlas = 0;
|
||||||
Color3B color = getColor();
|
V3F_C4B_T2F_Quad quad;
|
||||||
skeleton->r = color.r / (float)255;
|
quad.tl.vertices.z = 0;
|
||||||
skeleton->g = color.g / (float)255;
|
quad.tr.vertices.z = 0;
|
||||||
skeleton->b = color.b / (float)255;
|
quad.bl.vertices.z = 0;
|
||||||
skeleton->a = getOpacity() / (float)255;
|
quad.br.vertices.z = 0;
|
||||||
if (premultipliedAlpha) {
|
for (int i = 0, n = skeleton->slotCount; i < n; i++)
|
||||||
skeleton->r *= skeleton->a;
|
{
|
||||||
skeleton->g *= skeleton->a;
|
Slot* slot = skeleton->slots[i];
|
||||||
skeleton->b *= skeleton->a;
|
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;
|
if (debugSlots)
|
||||||
V3F_C4B_T2F_Quad quad;
|
{
|
||||||
quad.tl.vertices.z = 0;
|
// Slots.
|
||||||
quad.tr.vertices.z = 0;
|
DrawPrimitives::setDrawColor4B(0, 0, 255, 255);
|
||||||
quad.bl.vertices.z = 0;
|
glLineWidth(1);
|
||||||
quad.br.vertices.z = 0;
|
Point points[4];
|
||||||
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
|
V3F_C4B_T2F_Quad tmpQuad;
|
||||||
Slot* slot = skeleton->slots[i];
|
for (int i = 0, n = skeleton->slotCount; i < n; i++)
|
||||||
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
{
|
||||||
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
|
Slot* slot = skeleton->slots[i];
|
||||||
TextureAtlas* regionTextureAtlas = getTextureAtlas(attachment);
|
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
||||||
if (regionTextureAtlas != textureAtlas) {
|
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
|
||||||
if (textureAtlas) {
|
RegionAttachment_updateQuad(attachment, slot, &tmpQuad);
|
||||||
textureAtlas->drawQuads();
|
points[0] = Point(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y);
|
||||||
textureAtlas->removeAllQuads();
|
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);
|
||||||
textureAtlas = regionTextureAtlas;
|
DrawPrimitives::drawPoly(points, 4, true);
|
||||||
if (textureAtlas->getCapacity() == textureAtlas->getTotalQuads() &&
|
}
|
||||||
!textureAtlas->resizeCapacity(textureAtlas->getCapacity() * 2)) return;
|
}
|
||||||
RegionAttachment_updateQuad(attachment, slot, &quad, premultipliedAlpha);
|
if (debugBones)
|
||||||
textureAtlas->updateQuad(&quad, textureAtlas->getTotalQuads());
|
{
|
||||||
}
|
// Bone lengths.
|
||||||
if (textureAtlas) {
|
glLineWidth(2);
|
||||||
textureAtlas->drawQuads();
|
DrawPrimitives::setDrawColor4B(255, 0, 0, 255);
|
||||||
textureAtlas->removeAllQuads();
|
for (int i = 0, n = skeleton->boneCount; i < n; i++)
|
||||||
}
|
{
|
||||||
|
Bone *bone = skeleton->bones[i];
|
||||||
if (debugSlots) {
|
float x = bone->data->length * bone->m00 + bone->worldX;
|
||||||
// Slots.
|
float y = bone->data->length * bone->m10 + bone->worldY;
|
||||||
DrawPrimitives::setDrawColor4B(0, 0, 255, 255);
|
DrawPrimitives::drawLine(Point(bone->worldX, bone->worldY), Point(x, y));
|
||||||
glLineWidth(1);
|
}
|
||||||
Point points[4];
|
// Bone origins.
|
||||||
V3F_C4B_T2F_Quad tmpQuad;
|
DrawPrimitives::setPointSize(4);
|
||||||
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
|
DrawPrimitives::setDrawColor4B(0, 0, 255, 255); // Root bone is blue.
|
||||||
Slot* slot = skeleton->slots[i];
|
for (int i = 0, n = skeleton->boneCount; i < n; i++)
|
||||||
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
{
|
||||||
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
|
Bone *bone = skeleton->bones[i];
|
||||||
RegionAttachment_updateQuad(attachment, slot, &tmpQuad);
|
DrawPrimitives::drawPoint(Point(bone->worldX, bone->worldY));
|
||||||
points[0] = Point(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y);
|
if (i == 0) DrawPrimitives::setDrawColor4B(0, 255, 0, 255);
|
||||||
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 {
|
TextureAtlas* CCSkeleton::getTextureAtlas (RegionAttachment* regionAttachment) const {
|
||||||
return (TextureAtlas*)((AtlasRegion*)regionAttachment->rendererObject)->page->rendererObject;
|
return (TextureAtlas*)((AtlasRegion*)regionAttachment->rendererObject)->page->rendererObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect CCSkeleton::getBoundingBox() const {
|
Rect CCSkeleton::getBoundingBox() const {
|
||||||
float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN;
|
float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN;
|
||||||
float scaleX = getScaleX();
|
float scaleX = getScaleX();
|
||||||
float scaleY = getScaleY();
|
float scaleY = getScaleY();
|
||||||
float vertices[8];
|
float vertices[8];
|
||||||
for (int i = 0; i < skeleton->slotCount; ++i) {
|
for (int i = 0; i < skeleton->slotCount; ++i) {
|
||||||
Slot* slot = skeleton->slots[i];
|
Slot* slot = skeleton->slots[i];
|
||||||
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
||||||
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
|
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
|
||||||
RegionAttachment_computeVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices);
|
RegionAttachment_computeVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices);
|
||||||
minX = min(minX, vertices[VERTEX_X1] * scaleX);
|
minX = min(minX, vertices[VERTEX_X1] * scaleX);
|
||||||
minY = min(minY, vertices[VERTEX_Y1] * scaleY);
|
minY = min(minY, vertices[VERTEX_Y1] * scaleY);
|
||||||
maxX = max(maxX, vertices[VERTEX_X1] * scaleX);
|
maxX = max(maxX, vertices[VERTEX_X1] * scaleX);
|
||||||
maxY = max(maxY, vertices[VERTEX_Y1] * scaleY);
|
maxY = max(maxY, vertices[VERTEX_Y1] * scaleY);
|
||||||
minX = min(minX, vertices[VERTEX_X4] * scaleX);
|
minX = min(minX, vertices[VERTEX_X4] * scaleX);
|
||||||
minY = min(minY, vertices[VERTEX_Y4] * scaleY);
|
minY = min(minY, vertices[VERTEX_Y4] * scaleY);
|
||||||
maxX = max(maxX, vertices[VERTEX_X4] * scaleX);
|
maxX = max(maxX, vertices[VERTEX_X4] * scaleX);
|
||||||
maxY = max(maxY, vertices[VERTEX_Y4] * scaleY);
|
maxY = max(maxY, vertices[VERTEX_Y4] * scaleY);
|
||||||
minX = min(minX, vertices[VERTEX_X2] * scaleX);
|
minX = min(minX, vertices[VERTEX_X2] * scaleX);
|
||||||
minY = min(minY, vertices[VERTEX_Y2] * scaleY);
|
minY = min(minY, vertices[VERTEX_Y2] * scaleY);
|
||||||
maxX = max(maxX, vertices[VERTEX_X2] * scaleX);
|
maxX = max(maxX, vertices[VERTEX_X2] * scaleX);
|
||||||
maxY = max(maxY, vertices[VERTEX_Y2] * scaleY);
|
maxY = max(maxY, vertices[VERTEX_Y2] * scaleY);
|
||||||
minX = min(minX, vertices[VERTEX_X3] * scaleX);
|
minX = min(minX, vertices[VERTEX_X3] * scaleX);
|
||||||
minY = min(minY, vertices[VERTEX_Y3] * scaleY);
|
minY = min(minY, vertices[VERTEX_Y3] * scaleY);
|
||||||
maxX = max(maxX, vertices[VERTEX_X3] * scaleX);
|
maxX = max(maxX, vertices[VERTEX_X3] * scaleX);
|
||||||
maxY = max(maxY, vertices[VERTEX_Y3] * scaleY);
|
maxY = max(maxY, vertices[VERTEX_Y3] * scaleY);
|
||||||
}
|
}
|
||||||
Point position = getPosition();
|
Point position = getPosition();
|
||||||
return Rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY);
|
return Rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Convenience methods for Skeleton_* functions.
|
// --- Convenience methods for Skeleton_* functions.
|
||||||
|
|
||||||
void CCSkeleton::updateWorldTransform () {
|
void CCSkeleton::updateWorldTransform () {
|
||||||
Skeleton_updateWorldTransform(skeleton);
|
Skeleton_updateWorldTransform(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setToSetupPose () {
|
void CCSkeleton::setToSetupPose () {
|
||||||
Skeleton_setToSetupPose(skeleton);
|
Skeleton_setToSetupPose(skeleton);
|
||||||
}
|
}
|
||||||
void CCSkeleton::setBonesToSetupPose () {
|
void CCSkeleton::setBonesToSetupPose () {
|
||||||
Skeleton_setBonesToSetupPose(skeleton);
|
Skeleton_setBonesToSetupPose(skeleton);
|
||||||
}
|
}
|
||||||
void CCSkeleton::setSlotsToSetupPose () {
|
void CCSkeleton::setSlotsToSetupPose () {
|
||||||
Skeleton_setSlotsToSetupPose(skeleton);
|
Skeleton_setSlotsToSetupPose(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bone* CCSkeleton::findBone (const char* boneName) const {
|
Bone* CCSkeleton::findBone (const char* boneName) const {
|
||||||
return Skeleton_findBone(skeleton, boneName);
|
return Skeleton_findBone(skeleton, boneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Slot* CCSkeleton::findSlot (const char* slotName) const {
|
Slot* CCSkeleton::findSlot (const char* slotName) const {
|
||||||
return Skeleton_findSlot(skeleton, slotName);
|
return Skeleton_findSlot(skeleton, slotName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCSkeleton::setSkin (const char* skinName) {
|
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 {
|
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) {
|
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
|
// --- BlendProtocol
|
||||||
|
@ -280,11 +306,11 @@ void CCSkeleton::setBlendFunc( const BlendFunc &aBlendFunc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setOpacityModifyRGB (bool value) {
|
void CCSkeleton::setOpacityModifyRGB (bool value) {
|
||||||
premultipliedAlpha = value;
|
premultipliedAlpha = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCSkeleton::isOpacityModifyRGB () const {
|
bool CCSkeleton::isOpacityModifyRGB () const {
|
||||||
return premultipliedAlpha;
|
return premultipliedAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace spine {
|
} // namespace spine {
|
||||||
|
|
|
@ -248,6 +248,10 @@ static bool configureCURL(CURL *handle)
|
||||||
}
|
}
|
||||||
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L);
|
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||||
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 80567e2f54bf7c44375ce902e56d0ead37d362d0
|
Subproject commit 8f0159b894e47dd05ce454cf32f8d13bd4b39a63
|
|
@ -1 +1 @@
|
||||||
5bc5339bd77792b57c97cebbe7dfd3b634038e38
|
3194d28204e71875735934ee3207961ec14e655a
|
|
@ -60,6 +60,8 @@ bool SceneEditorTestLayer::init()
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ActionObject* actionObject = nullptr;
|
||||||
|
|
||||||
cocos2d::Node* SceneEditorTestLayer::createGameScene()
|
cocos2d::Node* SceneEditorTestLayer::createGameScene()
|
||||||
{
|
{
|
||||||
Node *pNode = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/FishJoy2.json");
|
Node *pNode = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/FishJoy2.json");
|
||||||
|
@ -79,12 +81,16 @@ cocos2d::Node* SceneEditorTestLayer::createGameScene()
|
||||||
pNode->addChild(menuBack);
|
pNode->addChild(menuBack);
|
||||||
|
|
||||||
//ui action
|
//ui action
|
||||||
ActionManagerEx::shareManager()->playActionByName("startMenu_1.json","Animation1");
|
actionObject = ActionManagerEx::shareManager()->playActionByName("startMenu_1.json","Animation1");
|
||||||
return pNode;
|
return pNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneEditorTestLayer::toExtensionsMainLayer(cocos2d::Object *sender)
|
void SceneEditorTestLayer::toExtensionsMainLayer(cocos2d::Object *sender)
|
||||||
{
|
{
|
||||||
|
if (actionObject)
|
||||||
|
{
|
||||||
|
actionObject->stop();
|
||||||
|
}
|
||||||
ComAudio *pBackMusic = (ComAudio*)(_curNode->getComponent("CCBackgroundAudio"));
|
ComAudio *pBackMusic = (ComAudio*)(_curNode->getComponent("CCBackgroundAudio"));
|
||||||
pBackMusic->stopBackgroundMusic();
|
pBackMusic->stopBackgroundMusic();
|
||||||
ExtensionsTestScene *pScene = new ExtensionsTestScene();
|
ExtensionsTestScene *pScene = new ExtensionsTestScene();
|
||||||
|
|
|
@ -67,22 +67,20 @@ MenuLayerMainMenu::MenuLayerMainMenu()
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
MenuItemFont::setFontName("Marker Felt");
|
MenuItemFont::setFontName("Marker Felt");
|
||||||
auto item6 = MenuItemFont::create("Priority Test", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackPriorityTest, this));
|
|
||||||
|
|
||||||
// Bugs Item
|
// 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
|
// 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_action = TintBy::create(0.5f, 0, -255, -255);
|
||||||
auto color_back = color_action->reverse();
|
auto color_back = color_action->reverse();
|
||||||
auto seq = Sequence::create(color_action, color_back, NULL);
|
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();
|
menu->alignItemsVertically();
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,14 +170,9 @@ void MenuLayerMainMenu::menuCallback2(Object* sender)
|
||||||
static_cast<LayerMultiplex*>(_parent)->switchTo(2);
|
static_cast<LayerMultiplex*>(_parent)->switchTo(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuLayerMainMenu::menuCallbackPriorityTest(Object* sender)
|
|
||||||
{
|
|
||||||
static_cast<LayerMultiplex*>(_parent)->switchTo(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuLayerMainMenu::menuCallbackBugsTest(Object *pSender)
|
void MenuLayerMainMenu::menuCallbackBugsTest(Object *pSender)
|
||||||
{
|
{
|
||||||
static_cast<LayerMultiplex*>(_parent)->switchTo(5);
|
static_cast<LayerMultiplex*>(_parent)->switchTo(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuLayerMainMenu::onQuit(Object* sender)
|
void MenuLayerMainMenu::onQuit(Object* sender)
|
||||||
|
@ -190,7 +183,7 @@ void MenuLayerMainMenu::onQuit(Object* sender)
|
||||||
|
|
||||||
void MenuLayerMainMenu::menuMovingCallback(Object *pSender)
|
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);
|
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::BugsTest()
|
BugsTest::BugsTest()
|
||||||
{
|
{
|
||||||
|
@ -621,11 +556,10 @@ void MenuTestScene::runThisTest()
|
||||||
auto layer2 = new MenuLayer2();
|
auto layer2 = new MenuLayer2();
|
||||||
auto layer3 = new MenuLayer3();
|
auto layer3 = new MenuLayer3();
|
||||||
auto layer4 = new MenuLayer4();
|
auto layer4 = new MenuLayer4();
|
||||||
auto layer5 = new MenuLayerPriorityTest();
|
auto layer5 = new BugsTest();
|
||||||
auto layer6 = new BugsTest();
|
auto layer6 = new RemoveMenuItemWhenMove();
|
||||||
auto layer7 = 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);
|
addChild(layer, 0);
|
||||||
|
|
||||||
layer1->release();
|
layer1->release();
|
||||||
|
@ -634,7 +568,6 @@ void MenuTestScene::runThisTest()
|
||||||
layer4->release();
|
layer4->release();
|
||||||
layer5->release();
|
layer5->release();
|
||||||
layer6->release();
|
layer6->release();
|
||||||
layer7->release();
|
|
||||||
|
|
||||||
Director::getInstance()->replaceScene(this);
|
Director::getInstance()->replaceScene(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,19 +79,6 @@ public:
|
||||||
//CREATE_NODE(MenuLayer4);
|
//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
|
class BugsTest : public Layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -151,8 +151,6 @@ public:
|
||||||
bool slice(PhysicsWorld& world, const PhysicsRayCastInfo& info, void* data);
|
bool slice(PhysicsWorld& world, const PhysicsRayCastInfo& info, void* data);
|
||||||
void clipPoly(PhysicsShapePolygon* shape, Point normal, float distance);
|
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);
|
void onTouchEnded(Touch *touch, Event *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -98,42 +98,35 @@ local function MenuLayerMainMenu()
|
||||||
-- Testing issue #500
|
-- Testing issue #500
|
||||||
item5:setScale( 0.8 )
|
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)
|
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(4)
|
||||||
end
|
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
|
-- Bugs Item
|
||||||
local item7 = cc.MenuItemFont:create("Bugs")
|
local item6 = cc.MenuItemFont:create("Bugs")
|
||||||
item7:registerScriptTapHandler(menuCallbackBugsTest)
|
item6:registerScriptTapHandler(menuCallbackBugsTest)
|
||||||
|
|
||||||
local function onQuit(sender)
|
local function onQuit(sender)
|
||||||
cclog("onQuit item is clicked.")
|
cclog("onQuit item is clicked.")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Font Item
|
-- Font Item
|
||||||
local item8 = cc.MenuItemFont:create("Quit")
|
local item7 = cc.MenuItemFont:create("Quit")
|
||||||
item8:registerScriptTapHandler(onQuit)
|
item7:registerScriptTapHandler(onQuit)
|
||||||
|
|
||||||
local function menuMovingCallback(pSender)
|
local function menuMovingCallback(pSender)
|
||||||
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(6)
|
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(5)
|
||||||
end
|
end
|
||||||
|
|
||||||
local item9 = cc.MenuItemFont:create("Remove menu item when moving")
|
local item8 = cc.MenuItemFont:create("Remove menu item when moving")
|
||||||
item9:registerScriptTapHandler(menuMovingCallback)
|
item8:registerScriptTapHandler(menuMovingCallback)
|
||||||
|
|
||||||
local color_action = cc.TintBy:create(0.5, 0, -255, -255)
|
local color_action = cc.TintBy:create(0.5, 0, -255, -255)
|
||||||
local color_back = color_action:reverse()
|
local color_back = color_action:reverse()
|
||||||
local seq = cc.Sequence:create(color_action, color_back)
|
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()
|
local menu = cc.Menu:create()
|
||||||
|
|
||||||
|
@ -145,7 +138,6 @@ local function MenuLayerMainMenu()
|
||||||
menu:addChild(item6)
|
menu:addChild(item6)
|
||||||
menu:addChild(item7)
|
menu:addChild(item7)
|
||||||
menu:addChild(item8)
|
menu:addChild(item8)
|
||||||
menu:addChild(item9)
|
|
||||||
|
|
||||||
menu:alignItemsVertically()
|
menu:alignItemsVertically()
|
||||||
|
|
||||||
|
@ -481,66 +473,6 @@ local function MenuLayer4()
|
||||||
return ret
|
return ret
|
||||||
end
|
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
|
-- BugsTest
|
||||||
local function BugsTest()
|
local function BugsTest()
|
||||||
local ret = cc.Layer:create()
|
local ret = cc.Layer:create()
|
||||||
|
@ -648,17 +580,15 @@ function MenuTestMain()
|
||||||
|
|
||||||
local pLayer3 = MenuLayer3()
|
local pLayer3 = MenuLayer3()
|
||||||
local pLayer4 = MenuLayer4()
|
local pLayer4 = MenuLayer4()
|
||||||
local pLayer5 = MenuLayerPriorityTest()
|
local pLayer5 = BugsTest()
|
||||||
local pLayer6 = BugsTest()
|
local pLayer6 = RemoveMenuItemWhenMove()
|
||||||
local pLayer7 = RemoveMenuItemWhenMove()
|
|
||||||
|
|
||||||
local layer = cc.LayerMultiplex:create(pLayer1,
|
local layer = cc.LayerMultiplex:create(pLayer1,
|
||||||
pLayer2,
|
pLayer2,
|
||||||
pLayer3,
|
pLayer3,
|
||||||
pLayer4,
|
pLayer4,
|
||||||
pLayer5,
|
pLayer5,
|
||||||
pLayer6,
|
pLayer6 )
|
||||||
pLayer7)
|
|
||||||
|
|
||||||
scene:addChild(layer, 0)
|
scene:addChild(layer, 0)
|
||||||
scene:addChild(CreateBackMenuItem())
|
scene:addChild(CreateBackMenuItem())
|
||||||
|
|
|
@ -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
|
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||||
# functions from all classes.
|
# 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],
|
Sprite::[getQuad getBlendFunc ^setPosition$ setBlendFunc],
|
||||||
SpriteBatchNode::[getBlendFunc setBlendFunc getDescendants],
|
SpriteBatchNode::[getBlendFunc setBlendFunc getDescendants],
|
||||||
MotionStreak::[getBlendFunc setBlendFunc draw update],
|
MotionStreak::[getBlendFunc setBlendFunc draw update],
|
||||||
|
|
Loading…
Reference in New Issue