mirror of https://github.com/axmolengine/axmol.git
Enum compatible [skip ci]
This commit is contained in:
parent
be5eff1d5a
commit
756ff065c8
|
@ -4,9 +4,8 @@ Copyright (c) 2010-2012 cocos2d-x.org
|
||||||
Copyright (c) 2011 Zynga Inc.
|
Copyright (c) 2011 Zynga Inc.
|
||||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
Copyright (c) Bytedance Inc.
|
|
||||||
|
|
||||||
https://adxe.org
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -54,16 +53,26 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
// Layer
|
// Layer
|
||||||
Layer::Layer()
|
Layer::Layer()
|
||||||
|
: _touchEnabled(false)
|
||||||
|
, _accelerometerEnabled(false)
|
||||||
|
, _keyboardEnabled(false)
|
||||||
|
, _touchListener(nullptr)
|
||||||
|
, _keyboardListener(nullptr)
|
||||||
|
, _accelerationListener(nullptr)
|
||||||
|
, _touchMode(Touch::DispatchMode::ALL_AT_ONCE)
|
||||||
|
, _swallowsTouches(true)
|
||||||
{
|
{
|
||||||
_ignoreAnchorPointForPosition = true;
|
_ignoreAnchorPointForPosition = true;
|
||||||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer::~Layer() {}
|
Layer::~Layer()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool Layer::init()
|
bool Layer::init()
|
||||||
{
|
{
|
||||||
Sprite::init();
|
|
||||||
setContentSize(_director->getWinSize());
|
setContentSize(_director->getWinSize());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -83,13 +92,204 @@ Layer* Layer::create()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Layer::executeScriptTouchHandler(EventTouch::EventCode eventType, Touch* touch, Event* event)
|
||||||
|
{
|
||||||
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
|
TouchScriptData data(eventType, this, touch, event);
|
||||||
|
ScriptEvent scriptEvent(kTouchEvent, &data);
|
||||||
|
return ScriptEngineManager::sendEventToLua(scriptEvent);
|
||||||
|
#else
|
||||||
|
CC_UNUSED_PARAM(eventType);
|
||||||
|
CC_UNUSED_PARAM(touch);
|
||||||
|
CC_UNUSED_PARAM(event);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int Layer::executeScriptTouchesHandler(EventTouch::EventCode eventType, const std::vector<Touch*>& touches, Event* event)
|
||||||
|
{
|
||||||
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
|
TouchesScriptData data(eventType, this, touches, event);
|
||||||
|
ScriptEvent scriptEvent(kTouchesEvent, &data);
|
||||||
|
return ScriptEngineManager::sendEventToLua(scriptEvent);
|
||||||
|
#else
|
||||||
|
CC_UNUSED_PARAM(eventType);
|
||||||
|
CC_UNUSED_PARAM(touches);
|
||||||
|
CC_UNUSED_PARAM(event);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Layer::onAcceleration(Acceleration* acc, Event* /*unused_event*/)
|
||||||
|
{
|
||||||
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
|
BasicScriptData data(this,(void*)acc);
|
||||||
|
ScriptEvent event(kAccelerometerEvent,&data);
|
||||||
|
ScriptEngineManager::sendEventToLua(event);
|
||||||
|
#else
|
||||||
|
CC_UNUSED_PARAM(acc);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layer::onKeyPressed(EventKeyboard::KeyCode /*keyCode*/, Event* /*unused_event*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layer::onKeyReleased(EventKeyboard::KeyCode keyCode, Event* /*unused_event*/)
|
||||||
|
{
|
||||||
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
|
KeypadScriptData data(keyCode, this);
|
||||||
|
ScriptEvent event(kKeypadEvent,&data);
|
||||||
|
ScriptEngineManager::sendEventToLua(event);
|
||||||
|
#else
|
||||||
|
CC_UNUSED_PARAM(keyCode);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Callbacks
|
||||||
|
|
||||||
|
bool Layer::onTouchBegan(Touch *touch, Event *event)
|
||||||
|
{
|
||||||
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
|
return executeScriptTouchHandler(EventTouch::EventCode::BEGAN, touch, event) == 0 ? false : true;
|
||||||
|
#else
|
||||||
|
CC_UNUSED_PARAM(touch);
|
||||||
|
CC_UNUSED_PARAM(event);
|
||||||
|
CCASSERT(false, "Layer#ccTouchBegan override me");
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layer::onTouchMoved(Touch *touch, Event *event)
|
||||||
|
{
|
||||||
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
|
executeScriptTouchHandler(EventTouch::EventCode::MOVED, touch, event);
|
||||||
|
#else
|
||||||
|
CC_UNUSED_PARAM(touch);
|
||||||
|
CC_UNUSED_PARAM(event);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layer::onTouchEnded(Touch *touch, Event *event)
|
||||||
|
{
|
||||||
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
|
executeScriptTouchHandler(EventTouch::EventCode::ENDED, touch, event);
|
||||||
|
#else
|
||||||
|
CC_UNUSED_PARAM(touch);
|
||||||
|
CC_UNUSED_PARAM(event);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layer::onTouchCancelled(Touch *touch, Event *event)
|
||||||
|
{
|
||||||
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
|
executeScriptTouchHandler(EventTouch::EventCode::CANCELLED, touch, event);
|
||||||
|
#else
|
||||||
|
CC_UNUSED_PARAM(touch);
|
||||||
|
CC_UNUSED_PARAM(event);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layer::onTouchesBegan(const std::vector<Touch*>& touches, Event *event)
|
||||||
|
{
|
||||||
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
|
executeScriptTouchesHandler(EventTouch::EventCode::BEGAN, touches, event);
|
||||||
|
#else
|
||||||
|
CC_UNUSED_PARAM(touches);
|
||||||
|
CC_UNUSED_PARAM(event);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layer::onTouchesMoved(const std::vector<Touch*>& touches, Event *event)
|
||||||
|
{
|
||||||
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
|
executeScriptTouchesHandler(EventTouch::EventCode::MOVED, touches, event);
|
||||||
|
#else
|
||||||
|
CC_UNUSED_PARAM(touches);
|
||||||
|
CC_UNUSED_PARAM(event);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layer::onTouchesEnded(const std::vector<Touch*>& touches, Event *event)
|
||||||
|
{
|
||||||
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
|
executeScriptTouchesHandler(EventTouch::EventCode::ENDED, touches, event);
|
||||||
|
#else
|
||||||
|
CC_UNUSED_PARAM(touches);
|
||||||
|
CC_UNUSED_PARAM(event);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layer::onTouchesCancelled(const std::vector<Touch*>& touches, Event *event)
|
||||||
|
{
|
||||||
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
|
executeScriptTouchesHandler(EventTouch::EventCode::CANCELLED, touches, event);
|
||||||
|
#else
|
||||||
|
CC_UNUSED_PARAM(touches);
|
||||||
|
CC_UNUSED_PARAM(event);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
std::string Layer::getDescription() const
|
std::string Layer::getDescription() const
|
||||||
{
|
{
|
||||||
return StringUtils::format("<Layer | Tag = %d>", _tag);
|
return StringUtils::format("<Layer | Tag = %d>", _tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// LayerColor
|
/// LayerColor
|
||||||
LayerColor::LayerColor() {}
|
|
||||||
|
LayerColor::LayerColor()
|
||||||
|
{
|
||||||
|
// default blend function
|
||||||
|
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
||||||
|
|
||||||
|
auto& pipelinePS = _customCommand.getPipelineDescriptor().programState;
|
||||||
|
auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR);
|
||||||
|
|
||||||
|
//!!! LayerColor private programState don't want affect by Node::_programState, so store at _customCommand
|
||||||
|
pipelinePS = new backend::ProgramState(program);
|
||||||
|
|
||||||
|
auto vertexLayout = pipelinePS->getVertexLayout();
|
||||||
|
const auto& attributeInfo = pipelinePS->getProgram()->getActiveAttributes();
|
||||||
|
auto iter = attributeInfo.find("a_position");
|
||||||
|
if(iter != attributeInfo.end())
|
||||||
|
{
|
||||||
|
vertexLayout->setAttribute("a_position", iter->second.location, backend::VertexFormat::FLOAT3, 0, false);
|
||||||
|
}
|
||||||
|
iter = attributeInfo.find("a_color");
|
||||||
|
if(iter != attributeInfo.end())
|
||||||
|
{
|
||||||
|
vertexLayout->setAttribute("a_color", iter->second.location, backend::VertexFormat::FLOAT4, sizeof(_vertexData[0].vertices), false);
|
||||||
|
}
|
||||||
|
vertexLayout->setLayout(sizeof(_vertexData[0]));
|
||||||
|
|
||||||
|
_mvpMatrixLocation = pipelinePS->getUniformLocation("u_MVPMatrix");
|
||||||
|
|
||||||
|
_customCommand.createIndexBuffer(CustomCommand::IndexFormat::U_SHORT, 6, CustomCommand::BufferUsage::STATIC);
|
||||||
|
unsigned short indices[] = {0, 1, 2, 2, 1, 3};
|
||||||
|
_customCommand.updateIndexBuffer(indices, sizeof(indices));
|
||||||
|
|
||||||
|
_customCommand.createVertexBuffer(sizeof(_vertexData[0]), 4, CustomCommand::BufferUsage::DYNAMIC);
|
||||||
|
|
||||||
|
_customCommand.setDrawType(CustomCommand::DrawType::ELEMENT);
|
||||||
|
_customCommand.setPrimitiveType(CustomCommand::PrimitiveType::TRIANGLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
LayerColor::~LayerColor()
|
||||||
|
{
|
||||||
|
CC_SAFE_RELEASE_NULL(_customCommand.getPipelineDescriptor().programState);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// blendFunc getter
|
||||||
|
const BlendFunc &LayerColor::getBlendFunc() const
|
||||||
|
{
|
||||||
|
return _blendFunc;
|
||||||
|
}
|
||||||
|
/// blendFunc setter
|
||||||
|
void LayerColor::setBlendFunc(const BlendFunc &var)
|
||||||
|
{
|
||||||
|
_blendFunc = var;
|
||||||
|
}
|
||||||
|
|
||||||
LayerColor* LayerColor::create()
|
LayerColor* LayerColor::create()
|
||||||
{
|
{
|
||||||
|
@ -137,17 +337,25 @@ bool LayerColor::init()
|
||||||
|
|
||||||
bool LayerColor::initWithColor(const Color4B& color, float w, float h)
|
bool LayerColor::initWithColor(const Color4B& color, float w, float h)
|
||||||
{
|
{
|
||||||
if (Sprite::init())
|
if (Layer::init())
|
||||||
{
|
{
|
||||||
// Anchor behavior same with Layer
|
|
||||||
_ignoreAnchorPointForPosition = true;
|
|
||||||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
|
||||||
|
|
||||||
const Rect defaultRect{0.f, 0.f, 2.f, 2.f};
|
// default blend function
|
||||||
setTextureRect(defaultRect, false, defaultRect.size);
|
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||||
|
|
||||||
|
_displayedColor.r = _realColor.r = color.r;
|
||||||
|
_displayedColor.g = _realColor.g = color.g;
|
||||||
|
_displayedColor.b = _realColor.b = color.b;
|
||||||
|
_displayedOpacity = _realOpacity = color.a;
|
||||||
|
|
||||||
|
for (size_t i = 0; i<sizeof(_squareVertices) / sizeof( _squareVertices[0]); i++ )
|
||||||
|
{
|
||||||
|
_squareVertices[i].x = 0.0f;
|
||||||
|
_squareVertices[i].y = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateColor();
|
||||||
setContentSize(Size(w, h));
|
setContentSize(Size(w, h));
|
||||||
setColor(Color3B{color});
|
|
||||||
setOpacity(color.a);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -160,6 +368,17 @@ bool LayerColor::initWithColor(const Color4B& color)
|
||||||
return initWithColor(color, s.width, s.height);
|
return initWithColor(color, s.width, s.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// override contentSize
|
||||||
|
void LayerColor::setContentSize(const Size & size)
|
||||||
|
{
|
||||||
|
_squareVertices[1].x = size.width;
|
||||||
|
_squareVertices[2].y = size.height;
|
||||||
|
_squareVertices[3].x = size.width;
|
||||||
|
_squareVertices[3].y = size.height;
|
||||||
|
|
||||||
|
Layer::setContentSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
void LayerColor::changeWidthAndHeight(float w ,float h)
|
void LayerColor::changeWidthAndHeight(float w ,float h)
|
||||||
{
|
{
|
||||||
this->setContentSize(Size(w, h));
|
this->setContentSize(Size(w, h));
|
||||||
|
@ -175,12 +394,52 @@ void LayerColor::changeHeight(float h)
|
||||||
this->setContentSize(Size(_contentSize.width, h));
|
this->setContentSize(Size(_contentSize.width, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LayerColor::updateColor()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; i++ )
|
||||||
|
{
|
||||||
|
_vertexData[i].colors.r = _displayedColor.r / 255.0f;
|
||||||
|
_vertexData[i].colors.g = _displayedColor.g / 255.0f;
|
||||||
|
_vertexData[i].colors.b = _displayedColor.b / 255.0f;
|
||||||
|
_vertexData[i].colors.a = _displayedOpacity / 255.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerColor::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||||
|
{
|
||||||
|
_customCommand.init(_globalZOrder, _blendFunc);
|
||||||
|
renderer->addCommand(&_customCommand);
|
||||||
|
|
||||||
|
cocos2d::Mat4 projectionMat = _director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||||
|
auto& pipelineDescriptor = _customCommand.getPipelineDescriptor();
|
||||||
|
pipelineDescriptor.programState->setUniform(_mvpMatrixLocation, projectionMat.m, sizeof(projectionMat.m));
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
Vec4 pos;
|
||||||
|
pos.x = _squareVertices[i].x; pos.y = _squareVertices[i].y; pos.z = _positionZ;
|
||||||
|
pos.w = 1;
|
||||||
|
_modelViewTransform.transformVector(&pos);
|
||||||
|
_vertexData[i].vertices = Vec3(pos.x,pos.y,pos.z)/pos.w;
|
||||||
|
}
|
||||||
|
updateVertexBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerColor::updateVertexBuffer()
|
||||||
|
{
|
||||||
|
_customCommand.updateVertexBuffer(_vertexData, sizeof(_vertexData));
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// LayerGradient
|
// LayerGradient
|
||||||
//
|
//
|
||||||
LayerGradient::LayerGradient() {}
|
LayerGradient::LayerGradient()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
LayerGradient::~LayerGradient() {}
|
LayerGradient::~LayerGradient()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end)
|
LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end)
|
||||||
{
|
{
|
||||||
|
@ -247,6 +506,8 @@ bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end, cons
|
||||||
|
|
||||||
void LayerGradient::updateColor()
|
void LayerGradient::updateColor()
|
||||||
{
|
{
|
||||||
|
LayerColor::updateColor();
|
||||||
|
|
||||||
float h = _alongVector.getLength();
|
float h = _alongVector.getLength();
|
||||||
if (h == 0)
|
if (h == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -263,42 +524,40 @@ void LayerGradient::updateColor()
|
||||||
|
|
||||||
float opacityf = (float)_displayedOpacity / 255.0f;
|
float opacityf = (float)_displayedOpacity / 255.0f;
|
||||||
|
|
||||||
Color4F S(_displayedColor.r / 255.0f, _displayedColor.g / 255.0f, _displayedColor.b / 255.0f,
|
Color4F S(
|
||||||
_startOpacity * opacityf / 255.0f);
|
_displayedColor.r / 255.0f,
|
||||||
|
_displayedColor.g / 255.0f,
|
||||||
|
_displayedColor.b / 255.0f,
|
||||||
|
_startOpacity * opacityf / 255.0f
|
||||||
|
);
|
||||||
|
|
||||||
Color4F E(_endColor.r / 255.0f, _endColor.g / 255.0f, _endColor.b / 255.0f, _endOpacity * opacityf / 255.0f);
|
Color4F E(
|
||||||
|
_endColor.r / 255.0f,
|
||||||
|
_endColor.g / 255.0f,
|
||||||
|
_endColor.b / 255.0f,
|
||||||
|
_endOpacity * opacityf / 255.0f
|
||||||
|
);
|
||||||
|
|
||||||
// (-1, -1)
|
// (-1, -1)
|
||||||
_quad.bl.colors.r = (E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c))) * 255;
|
_vertexData[0].colors.r = E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c));
|
||||||
_quad.bl.colors.g = (E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0f * c))) * 255;
|
_vertexData[0].colors.g = E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0f * c));
|
||||||
_quad.bl.colors.b = (E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0f * c))) * 255;
|
_vertexData[0].colors.b = E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0f * c));
|
||||||
_quad.bl.colors.a = (E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0f * c))) * 255;
|
_vertexData[0].colors.a = E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0f * c));
|
||||||
// (1, -1)
|
// (1, -1)
|
||||||
_quad.br.colors.r = (E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0f * c))) * 255;
|
_vertexData[1].colors.r = E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0f * c));
|
||||||
_quad.br.colors.g = (E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0f * c))) * 255;
|
_vertexData[1].colors.g = E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0f * c));
|
||||||
_quad.br.colors.b = (E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0f * c))) * 255;
|
_vertexData[1].colors.b = E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0f * c));
|
||||||
_quad.br.colors.a = (E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0f * c))) * 255;
|
_vertexData[1].colors.a = E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0f * c));
|
||||||
// (-1, 1)
|
// (-1, 1)
|
||||||
_quad.tl.colors.r = (E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0f * c))) * 255;
|
_vertexData[2].colors.r = E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0f * c));
|
||||||
_quad.tl.colors.g = (E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0f * c))) * 255;
|
_vertexData[2].colors.g = E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0f * c));
|
||||||
_quad.tl.colors.b = (E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0f * c))) * 255;
|
_vertexData[2].colors.b = E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0f * c));
|
||||||
_quad.tl.colors.a = (E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0f * c))) * 255;
|
_vertexData[2].colors.a = E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0f * c));
|
||||||
// (1, 1)
|
// (1, 1)
|
||||||
_quad.tr.colors.r = (E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0f * c))) * 255;
|
_vertexData[3].colors.r = E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0f * c));
|
||||||
_quad.tr.colors.g = (E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0f * c))) * 255;
|
_vertexData[3].colors.g = E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0f * c));
|
||||||
_quad.tr.colors.b = (E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0f * c))) * 255;
|
_vertexData[3].colors.b = E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0f * c));
|
||||||
_quad.tr.colors.a = (E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c))) * 255;
|
_vertexData[3].colors.a = E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c));
|
||||||
|
|
||||||
// renders using batch node
|
|
||||||
if (_renderMode == RenderMode::QUAD_BATCHNODE)
|
|
||||||
{
|
|
||||||
if (_atlasIndex != INDEX_NOT_INITIALIZED)
|
|
||||||
_textureAtlas->updateQuad(&_quad, _atlasIndex);
|
|
||||||
else
|
|
||||||
// no need to set it recursively
|
|
||||||
// update dirty_, don't update recursiveDirty_
|
|
||||||
setDirty(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Color3B& LayerGradient::getStartColor() const
|
const Color3B& LayerGradient::getStartColor() const
|
||||||
|
@ -374,11 +633,7 @@ std::string LayerGradient::getDescription() const
|
||||||
/**
|
/**
|
||||||
* LayerRadialGradient
|
* LayerRadialGradient
|
||||||
*/
|
*/
|
||||||
LayerRadialGradient* LayerRadialGradient::create(const Color4B& startColor,
|
LayerRadialGradient* LayerRadialGradient::create(const Color4B& startColor, const Color4B& endColor, float radius, const Vec2& center, float expand)
|
||||||
const Color4B& endColor,
|
|
||||||
float radius,
|
|
||||||
const Vec2& center,
|
|
||||||
float expand)
|
|
||||||
{
|
{
|
||||||
auto layerGradient = new LayerRadialGradient();
|
auto layerGradient = new LayerRadialGradient();
|
||||||
if (layerGradient && layerGradient->initWithColor(startColor, endColor, radius, center, expand))
|
if (layerGradient && layerGradient->initWithColor(startColor, endColor, radius, center, expand))
|
||||||
|
@ -426,8 +681,7 @@ LayerRadialGradient::LayerRadialGradient()
|
||||||
}
|
}
|
||||||
vertexLayout->setLayout(sizeof(_vertices[0]));
|
vertexLayout->setLayout(sizeof(_vertices[0]));
|
||||||
|
|
||||||
_customCommand.createVertexBuffer(sizeof(_vertices[0]), sizeof(_vertices) / sizeof(_vertices[0]),
|
_customCommand.createVertexBuffer(sizeof(_vertices[0]), sizeof(_vertices) / sizeof(_vertices[0]), CustomCommand::BufferUsage::STATIC);
|
||||||
CustomCommand::BufferUsage::STATIC);
|
|
||||||
_customCommand.setDrawType(CustomCommand::DrawType::ARRAY);
|
_customCommand.setDrawType(CustomCommand::DrawType::ARRAY);
|
||||||
_customCommand.setPrimitiveType(CustomCommand::PrimitiveType::TRIANGLE_STRIP);
|
_customCommand.setPrimitiveType(CustomCommand::PrimitiveType::TRIANGLE_STRIP);
|
||||||
}
|
}
|
||||||
|
@ -437,11 +691,7 @@ LayerRadialGradient::~LayerRadialGradient()
|
||||||
CC_SAFE_RELEASE_NULL(_customCommand.getPipelineDescriptor().programState);
|
CC_SAFE_RELEASE_NULL(_customCommand.getPipelineDescriptor().programState);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LayerRadialGradient::initWithColor(const cocos2d::Color4B& startColor,
|
bool LayerRadialGradient::initWithColor(const cocos2d::Color4B &startColor, const cocos2d::Color4B &endColor, float radius, const Vec2& center, float expand)
|
||||||
const cocos2d::Color4B& endColor,
|
|
||||||
float radius,
|
|
||||||
const Vec2& center,
|
|
||||||
float expand)
|
|
||||||
{
|
{
|
||||||
// should do it before Layer::init()
|
// should do it before Layer::init()
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
|
@ -588,6 +838,16 @@ Color3B LayerRadialGradient::getEndColor3B() const
|
||||||
return Color3B(_endColor);
|
return Color3B(_endColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LayerRadialGradient::setBlendFunc(const BlendFunc& blendFunc)
|
||||||
|
{
|
||||||
|
_blendFunc = blendFunc;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlendFunc LayerRadialGradient::getBlendFunc() const
|
||||||
|
{
|
||||||
|
return _blendFunc;
|
||||||
|
}
|
||||||
|
|
||||||
void LayerRadialGradient::convertColor4B24F(Color4F& outColor, const Color4B& inColor)
|
void LayerRadialGradient::convertColor4B24F(Color4F& outColor, const Color4B& inColor)
|
||||||
{
|
{
|
||||||
outColor.r = inColor.r / 255.0f;
|
outColor.r = inColor.r / 255.0f;
|
||||||
|
@ -596,14 +856,17 @@ void LayerRadialGradient::convertColor4B24F(Color4F& outColor, const Color4B& in
|
||||||
outColor.a = inColor.a / 255.0f;
|
outColor.a = inColor.a / 255.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// MultiplexLayer
|
/// MultiplexLayer
|
||||||
|
|
||||||
LayerMultiplex::LayerMultiplex() : _enabledLayer(0) {}
|
LayerMultiplex::LayerMultiplex()
|
||||||
|
: _enabledLayer(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
LayerMultiplex::~LayerMultiplex()
|
LayerMultiplex::~LayerMultiplex()
|
||||||
{
|
{
|
||||||
for (const auto& layer : _layers)
|
for(const auto &layer : _layers) {
|
||||||
{
|
|
||||||
layer->cleanup();
|
layer->cleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -695,8 +958,7 @@ bool LayerMultiplex::initWithLayers(Layer* layer, va_list params)
|
||||||
_layers.pushBack(layer);
|
_layers.pushBack(layer);
|
||||||
|
|
||||||
Layer *l = va_arg(params,Layer*);
|
Layer *l = va_arg(params,Layer*);
|
||||||
while (l)
|
while( l ) {
|
||||||
{
|
|
||||||
#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS
|
#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS
|
||||||
if (sEngine)
|
if (sEngine)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,9 +3,9 @@ Copyright (c) 2008-2010 Ricardo Quesada
|
||||||
Copyright (c) 2010-2012 cocos2d-x.org
|
Copyright (c) 2010-2012 cocos2d-x.org
|
||||||
Copyright (c) 2011 Zynga Inc.
|
Copyright (c) 2011 Zynga Inc.
|
||||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||||
Copyright (c) Bytedance Inc.
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
|
|
||||||
https://adxe.org
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -28,7 +28,6 @@ THE SOFTWARE.
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "2d/CCNode.h"
|
#include "2d/CCNode.h"
|
||||||
#include "2d/CCSprite.h"
|
|
||||||
#include "base/CCProtocols.h"
|
#include "base/CCProtocols.h"
|
||||||
#include "renderer/CCCustomCommand.h"
|
#include "renderer/CCCustomCommand.h"
|
||||||
|
|
||||||
|
@ -41,13 +40,26 @@ NS_CC_BEGIN
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
class __Set;
|
||||||
|
class TouchScriptHandlerEntry;
|
||||||
|
|
||||||
|
class EventListenerTouch;
|
||||||
|
class EventListenerKeyboard;
|
||||||
|
class EventListenerAcceleration;
|
||||||
|
|
||||||
|
class Touch;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Layer
|
// Layer
|
||||||
//
|
//
|
||||||
/** @class Layer
|
/** @class Layer
|
||||||
* @brief Layer is a subclass of Node
|
* @brief Layer is a subclass of Node that implements the TouchEventsDelegate protocol.
|
||||||
|
|
||||||
|
All features from Node are valid, plus the following new features:
|
||||||
|
- It can receive iPhone Touches
|
||||||
|
- It can receive Accelerometer input
|
||||||
*/
|
*/
|
||||||
class CC_DLL Layer : public Sprite
|
class CC_DLL Layer : public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Creates a fullscreen black layer.
|
/** Creates a fullscreen black layer.
|
||||||
|
@ -56,6 +68,95 @@ public:
|
||||||
*/
|
*/
|
||||||
static Layer *create();
|
static Layer *create();
|
||||||
|
|
||||||
|
/* Callback function should not be deprecated, it will generate lots of warnings.
|
||||||
|
Since 'setTouchEnabled' was deprecated, it will make warnings if developer overrides onTouchXXX and invokes setTouchEnabled(true) instead of using EventDispatcher::addEventListenerWithXXX.
|
||||||
|
*/
|
||||||
|
/** Callback function for touch began.
|
||||||
|
*
|
||||||
|
* @param touch Touch information.
|
||||||
|
* @param unused_event Event information.
|
||||||
|
* @return if return false, onTouchMoved, onTouchEnded, onTouchCancelled will never called.
|
||||||
|
* @js NA
|
||||||
|
*/
|
||||||
|
virtual bool onTouchBegan(Touch *touch, Event *unused_event);
|
||||||
|
/** Callback function for touch moved.
|
||||||
|
*
|
||||||
|
* @param touch Touch information.
|
||||||
|
* @param unused_event Event information.
|
||||||
|
* @js NA
|
||||||
|
*/
|
||||||
|
virtual void onTouchMoved(Touch *touch, Event *unused_event);
|
||||||
|
/** Callback function for touch ended.
|
||||||
|
*
|
||||||
|
* @param touch Touch information.
|
||||||
|
* @param unused_event Event information.
|
||||||
|
* @js NA
|
||||||
|
*/
|
||||||
|
virtual void onTouchEnded(Touch *touch, Event *unused_event);
|
||||||
|
/** Callback function for touch cancelled.
|
||||||
|
*
|
||||||
|
* @param touch Touch information.
|
||||||
|
* @param unused_event Event information.
|
||||||
|
* @js NA
|
||||||
|
*/
|
||||||
|
virtual void onTouchCancelled(Touch *touch, Event *unused_event);
|
||||||
|
|
||||||
|
/** Callback function for multiple touches began.
|
||||||
|
*
|
||||||
|
* @param touches Touches information.
|
||||||
|
* @param unused_event Event information.
|
||||||
|
* @js NA
|
||||||
|
*/
|
||||||
|
virtual void onTouchesBegan(const std::vector<Touch*>& touches, Event *unused_event);
|
||||||
|
/** Callback function for multiple touches moved.
|
||||||
|
*
|
||||||
|
* @param touches Touches information.
|
||||||
|
* @param unused_event Event information.
|
||||||
|
* @js NA
|
||||||
|
*/
|
||||||
|
virtual void onTouchesMoved(const std::vector<Touch*>& touches, Event *unused_event);
|
||||||
|
/** Callback function for multiple touches ended.
|
||||||
|
*
|
||||||
|
* @param touches Touches information.
|
||||||
|
* @param unused_event Event information.
|
||||||
|
* @js NA
|
||||||
|
*/
|
||||||
|
virtual void onTouchesEnded(const std::vector<Touch*>& touches, Event *unused_event);
|
||||||
|
/** Callback function for multiple touches cancelled.
|
||||||
|
*
|
||||||
|
* @param touches Touches information.
|
||||||
|
* @param unused_event Event information.
|
||||||
|
* @js NA
|
||||||
|
*/
|
||||||
|
virtual void onTouchesCancelled(const std::vector<Touch*>&touches, Event *unused_event);
|
||||||
|
|
||||||
|
/* Callback function should not be deprecated, it will generate lots of warnings.
|
||||||
|
Since 'setAccelerometerEnabled' was deprecated, it will make warnings if developer overrides onAcceleration and invokes setAccelerometerEnabled(true) instead of using EventDispatcher::addEventListenerWithXXX.
|
||||||
|
*/
|
||||||
|
/** Callback function for acceleration.
|
||||||
|
* @param acc Acceleration information.
|
||||||
|
* @param unused_event Event information.
|
||||||
|
* @js NA
|
||||||
|
*/
|
||||||
|
virtual void onAcceleration(Acceleration* acc, Event* unused_event);
|
||||||
|
|
||||||
|
|
||||||
|
/* Callback function should not be deprecated, it will generate lots of warnings.
|
||||||
|
Since 'setKeyboardEnabled' was deprecated, it will make warnings if developer overrides onKeyXXX and invokes setKeyboardEnabled(true) instead of using EventDispatcher::addEventListenerWithXXX.
|
||||||
|
*/
|
||||||
|
/** Callback function for key pressed.
|
||||||
|
* @param keyCode KeyCode information.
|
||||||
|
* @param event Event information.
|
||||||
|
* @js NA
|
||||||
|
*/
|
||||||
|
virtual void onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event);
|
||||||
|
/** Callback function for key released.
|
||||||
|
* @param keyCode KeyCode information.
|
||||||
|
* @param event Event information.
|
||||||
|
* @js NA
|
||||||
|
*/
|
||||||
|
virtual void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event);
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual std::string getDescription() const override;
|
virtual std::string getDescription() const override;
|
||||||
|
|
||||||
|
@ -65,6 +166,21 @@ CC_CONSTRUCTOR_ACCESS:
|
||||||
|
|
||||||
virtual bool init() override;
|
virtual bool init() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
int executeScriptTouchHandler(EventTouch::EventCode eventType, Touch* touch, Event* event);
|
||||||
|
int executeScriptTouchesHandler(EventTouch::EventCode eventType, const std::vector<Touch*>& touches, Event* event);
|
||||||
|
|
||||||
|
bool _touchEnabled;
|
||||||
|
bool _accelerometerEnabled;
|
||||||
|
bool _keyboardEnabled;
|
||||||
|
EventListener* _touchListener;
|
||||||
|
EventListenerKeyboard* _keyboardListener;
|
||||||
|
EventListenerAcceleration* _accelerationListener;
|
||||||
|
|
||||||
|
Touch::DispatchMode _touchMode;
|
||||||
|
bool _swallowsTouches;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_COPY_AND_ASSIGN(Layer);
|
CC_DISALLOW_COPY_AND_ASSIGN(Layer);
|
||||||
|
|
||||||
|
@ -80,7 +196,7 @@ All features from Layer are valid, plus the following new features:
|
||||||
- opacity
|
- opacity
|
||||||
- RGB colors
|
- RGB colors
|
||||||
*/
|
*/
|
||||||
class CC_DLL LayerColor : public Layer
|
class CC_DLL LayerColor : public Layer, public BlendProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -122,12 +238,46 @@ public:
|
||||||
*/
|
*/
|
||||||
void changeWidthAndHeight(float w, float h);
|
void changeWidthAndHeight(float w, float h);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Overrides
|
||||||
|
//
|
||||||
|
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||||
|
|
||||||
|
virtual void setContentSize(const Size & var) override;
|
||||||
|
/** BlendFunction. Conforms to BlendProtocol protocol */
|
||||||
|
/**
|
||||||
|
* @lua NA
|
||||||
|
*/
|
||||||
|
virtual const BlendFunc& getBlendFunc() const override;
|
||||||
|
/**
|
||||||
|
*@code
|
||||||
|
*When this function bound into js or lua,the parameter will be changed
|
||||||
|
*In js: var setBlendFunc(var src, var dst)
|
||||||
|
*In lua: local setBlendFunc(local src, local dst)
|
||||||
|
*@endcode
|
||||||
|
*/
|
||||||
|
virtual void setBlendFunc(const BlendFunc& blendFunc) override;
|
||||||
|
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
LayerColor();
|
LayerColor();
|
||||||
|
virtual ~LayerColor();
|
||||||
|
|
||||||
bool init() override;
|
bool init() override;
|
||||||
bool initWithColor(const Color4B& color, float width, float height);
|
bool initWithColor(const Color4B& color, float width, float height);
|
||||||
bool initWithColor(const Color4B& color);
|
bool initWithColor(const Color4B& color);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void updateColor() override;
|
||||||
|
void updateVertexBuffer();
|
||||||
|
|
||||||
|
BlendFunc _blendFunc;
|
||||||
|
Vec2 _squareVertices[4];
|
||||||
|
CustomCommand _customCommand;
|
||||||
|
|
||||||
|
V3F_C4F _vertexData[4];
|
||||||
|
|
||||||
|
backend::UniformLocation _mvpMatrixLocation;
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_COPY_AND_ASSIGN(LayerColor);
|
CC_DISALLOW_COPY_AND_ASSIGN(LayerColor);
|
||||||
|
|
||||||
|
@ -330,6 +480,9 @@ public:
|
||||||
Color4B getEndColor() const;
|
Color4B getEndColor() const;
|
||||||
Color3B getEndColor3B() const;
|
Color3B getEndColor3B() const;
|
||||||
|
|
||||||
|
void setBlendFunc(const BlendFunc& blendFunc);
|
||||||
|
BlendFunc getBlendFunc() const;
|
||||||
|
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
LayerRadialGradient();
|
LayerRadialGradient();
|
||||||
virtual ~LayerRadialGradient();
|
virtual ~LayerRadialGradient();
|
||||||
|
@ -351,6 +504,8 @@ private:
|
||||||
float _expand = 0.f;
|
float _expand = 0.f;
|
||||||
CustomCommand _customCommand;
|
CustomCommand _customCommand;
|
||||||
|
|
||||||
|
BlendFunc _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||||
|
|
||||||
backend::UniformLocation _mvpMatrixLocation;
|
backend::UniformLocation _mvpMatrixLocation;
|
||||||
backend::UniformLocation _startColorLocation;
|
backend::UniformLocation _startColorLocation;
|
||||||
backend::UniformLocation _endColorLocation;
|
backend::UniformLocation _endColorLocation;
|
||||||
|
|
|
@ -139,10 +139,10 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void setEnabled(bool value) { _enabled = value; };
|
virtual void setEnabled(bool value) { _enabled = value; };
|
||||||
|
|
||||||
virtual bool onTouchBegan(Touch* touch, Event* event);
|
virtual bool onTouchBegan(Touch* touch, Event* event) override;
|
||||||
virtual void onTouchEnded(Touch* touch, Event* event);
|
virtual void onTouchEnded(Touch* touch, Event* event) override;
|
||||||
virtual void onTouchCancelled(Touch* touch, Event* event);
|
virtual void onTouchCancelled(Touch* touch, Event* event) override;
|
||||||
virtual void onTouchMoved(Touch* touch, Event* event);
|
virtual void onTouchMoved(Touch* touch, Event* event) override;
|
||||||
|
|
||||||
// overrides
|
// overrides
|
||||||
virtual void removeChild(Node* child, bool cleanup) override;
|
virtual void removeChild(Node* child, bool cleanup) override;
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
|
Copyright (c) Bytedance Inc.
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
https://adxe.org
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -120,9 +121,9 @@ public:
|
||||||
{
|
{
|
||||||
ABSOLUTE,
|
ABSOLUTE,
|
||||||
VERTICAL,
|
VERTICAL,
|
||||||
CENTER_VERTICAL,
|
|
||||||
HORIZONTAL,
|
HORIZONTAL,
|
||||||
RELATIVE
|
RELATIVE,
|
||||||
|
CENTER_VERTICAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -157,10 +157,10 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual Vec2 getTouchLocation(Touch* touch);
|
virtual Vec2 getTouchLocation(Touch* touch);
|
||||||
|
|
||||||
virtual bool onTouchBegan(Touch* touch, Event* event);
|
virtual bool onTouchBegan(Touch* touch, Event* event) override;
|
||||||
virtual void onTouchMoved(Touch* touch, Event* event);
|
virtual void onTouchMoved(Touch* touch, Event* event) override;
|
||||||
virtual void onTouchEnded(Touch* touch, Event* event);
|
virtual void onTouchEnded(Touch* touch, Event* event) override;
|
||||||
virtual void onTouchCancelled(Touch* touch, Event* event);
|
virtual void onTouchCancelled(Touch* touch, Event* event) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a boolean value that indicates whether a touch is inside the bounds
|
* Returns a boolean value that indicates whether a touch is inside the bounds
|
||||||
|
|
|
@ -241,10 +241,10 @@ public:
|
||||||
bool isClippingToBounds() { return _clippingToBounds; }
|
bool isClippingToBounds() { return _clippingToBounds; }
|
||||||
void setClippingToBounds(bool bClippingToBounds) { _clippingToBounds = bClippingToBounds; }
|
void setClippingToBounds(bool bClippingToBounds) { _clippingToBounds = bClippingToBounds; }
|
||||||
|
|
||||||
virtual bool onTouchBegan(Touch *touch, Event *event);
|
virtual bool onTouchBegan(Touch *touch, Event *event) override;
|
||||||
virtual void onTouchMoved(Touch *touch, Event *event);
|
virtual void onTouchMoved(Touch *touch, Event *event) override;
|
||||||
virtual void onTouchEnded(Touch *touch, Event *event);
|
virtual void onTouchEnded(Touch *touch, Event *event) override;
|
||||||
virtual void onTouchCancelled(Touch *touch, Event *event);
|
virtual void onTouchCancelled(Touch *touch, Event *event) override;
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual void setContentSize(const Size & size) override;
|
virtual void setContentSize(const Size & size) override;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2325,6 +2325,10 @@ int register_all_cocos2dx(lua_State* tolua_S);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,8 @@ public:
|
||||||
void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event* event);
|
void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event* event);
|
||||||
void onTouchEnded(cocos2d::Touch* touch, cocos2d::Event* event);
|
void onTouchEnded(cocos2d::Touch* touch, cocos2d::Event* event);
|
||||||
|
|
||||||
void onKeyPressed(cocos2d::EventKeyboard::KeyCode code, cocos2d::Event* event);
|
void onKeyPressed(cocos2d::EventKeyboard::KeyCode code, cocos2d::Event* event) override;
|
||||||
void onKeyReleased(cocos2d::EventKeyboard::KeyCode code, cocos2d::Event* event);
|
void onKeyReleased(cocos2d::EventKeyboard::KeyCode code, cocos2d::Event* event) override;
|
||||||
|
|
||||||
void onMouseDown(cocos2d::Event* event);
|
void onMouseDown(cocos2d::Event* event);
|
||||||
void onMouseUp(cocos2d::Event* event);
|
void onMouseUp(cocos2d::Event* event);
|
||||||
|
|
|
@ -135,7 +135,7 @@ void UIRadioButtonTest::deleteRadioButton(Ref* sender)
|
||||||
{
|
{
|
||||||
RadioButton* radioButton = _radioButtonGroup->getRadioButtonByIndex((int)_radioButtonGroup->getNumberOfRadioButtons() - 1);
|
RadioButton* radioButton = _radioButtonGroup->getRadioButtonByIndex((int)_radioButtonGroup->getNumberOfRadioButtons() - 1);
|
||||||
_radioButtonGroup->removeRadioButton(radioButton);
|
_radioButtonGroup->removeRadioButton(radioButton);
|
||||||
_uiLayer->removeChild(radioButton, true);
|
_uiLayer->removeChild(radioButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue