mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-04 10:32:39 +08:00
Merge pull request #56 from WenhaiLin/master-temp-objects
Avoid creating short-term temporary `Vec2` objects
This commit is contained in:
@@ -130,8 +130,8 @@ void FlipX3D::update(float time)
|
||||
|
||||
Vec3 v0, v1, v, diff;
|
||||
|
||||
v0 = getOriginalVertex(Vec2(1.0f, 1.0f));
|
||||
v1 = getOriginalVertex(Vec2());
|
||||
v0 = getOriginalVertex(Vec2::ONE);
|
||||
v1 = getOriginalVertex(Vec2::ZERO);
|
||||
|
||||
float x0 = v0.x;
|
||||
float x1 = v1.x;
|
||||
@@ -224,8 +224,8 @@ void FlipY3D::update(float time)
|
||||
|
||||
Vec3 v0, v1, v, diff;
|
||||
|
||||
v0 = getOriginalVertex(Vec2(1.0f, 1.0f));
|
||||
v1 = getOriginalVertex(Vec2());
|
||||
v0 = getOriginalVertex(Vec2::ONE);
|
||||
v1 = getOriginalVertex(Vec2::ZERO);
|
||||
|
||||
float y0 = v0.y;
|
||||
float y1 = v1.y;
|
||||
|
||||
@@ -823,7 +823,7 @@ void TMXLayer::setupTileSprite(Sprite* sprite, Vec2 pos, int gid)
|
||||
if (gid & kTMXTileDiagonalFlag)
|
||||
{
|
||||
// put the anchor in the middle for ease of rotation.
|
||||
sprite->setAnchorPoint(Vec2(0.5f,0.5f));
|
||||
sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
sprite->setPosition(getPositionAt(pos).x + sprite->getContentSize().height/2,
|
||||
getPositionAt(pos).y + sprite->getContentSize().width/2 );
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ NS_CC_BEGIN
|
||||
Layer::Layer()
|
||||
{
|
||||
_ignoreAnchorPointForPosition = true;
|
||||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
}
|
||||
|
||||
Layer::~Layer()
|
||||
|
||||
@@ -137,7 +137,7 @@ bool Menu::initWithArray(const Vector<MenuItem*>& arrayOfItems)
|
||||
Size s = _director->getWinSize();
|
||||
|
||||
this->ignoreAnchorPointForPosition(true);
|
||||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
this->setContentSize(s);
|
||||
|
||||
setPosition(s.width/2, s.height/2);
|
||||
|
||||
@@ -60,7 +60,7 @@ MenuItem* MenuItem::create( const ccMenuCallback& callback)
|
||||
|
||||
bool MenuItem::initWithCallback(const ccMenuCallback& callback)
|
||||
{
|
||||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
_callback = callback;
|
||||
_enabled = true;
|
||||
_selected = false;
|
||||
@@ -404,7 +404,7 @@ void MenuItemSprite::setSelectedImage(Node* image)
|
||||
if (image)
|
||||
{
|
||||
addChild(image);
|
||||
image->setAnchorPoint(Vec2(0, 0));
|
||||
image->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
|
||||
}
|
||||
|
||||
if (_selectedImage)
|
||||
@@ -424,7 +424,7 @@ void MenuItemSprite::setDisabledImage(Node* image)
|
||||
if (image)
|
||||
{
|
||||
addChild(image);
|
||||
image->setAnchorPoint(Vec2(0, 0));
|
||||
image->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
|
||||
}
|
||||
|
||||
if (_disabledImage)
|
||||
|
||||
@@ -307,7 +307,7 @@ bool ParticleSun::initWithTotalParticles(int numberOfParticles)
|
||||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vec2(0,0));
|
||||
setGravity(Vec2::ZERO);
|
||||
|
||||
// Gravity mode: radial acceleration
|
||||
setRadialAccel(0);
|
||||
@@ -411,7 +411,7 @@ bool ParticleGalaxy::initWithTotalParticles(int numberOfParticles)
|
||||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vec2(0,0));
|
||||
setGravity(Vec2::ZERO);
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(60);
|
||||
@@ -520,7 +520,7 @@ bool ParticleFlower::initWithTotalParticles(int numberOfParticles)
|
||||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vec2(0,0));
|
||||
setGravity(Vec2::ZERO);
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(80);
|
||||
@@ -737,7 +737,7 @@ bool ParticleSpiral::initWithTotalParticles(int numberOfParticles)
|
||||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vec2(0,0));
|
||||
setGravity(Vec2::ZERO);
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(150);
|
||||
@@ -845,7 +845,7 @@ bool ParticleExplosion::initWithTotalParticles(int numberOfParticles)
|
||||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vec2(0,0));
|
||||
setGravity(Vec2::ZERO);
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(70);
|
||||
@@ -954,7 +954,7 @@ bool ParticleSmoke::initWithTotalParticles(int numberOfParticles)
|
||||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vec2(0,0));
|
||||
setGravity(Vec2::ZERO);
|
||||
|
||||
// Gravity Mode: radial acceleration
|
||||
setRadialAccel(0);
|
||||
|
||||
@@ -73,11 +73,11 @@ bool ProgressTimer::initWithSprite(Sprite* sp)
|
||||
_vertexData = nullptr;
|
||||
_vertexDataCount = 0;
|
||||
|
||||
setAnchorPoint(Vec2(0.5f,0.5f));
|
||||
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
_type = Type::RADIAL;
|
||||
_reverseDirection = false;
|
||||
setMidpoint(Vec2(0.5f, 0.5f));
|
||||
setBarChangeRate(Vec2(1,1));
|
||||
setMidpoint(Vec2::ANCHOR_MIDDLE);
|
||||
setBarChangeRate(Vec2::ONE);
|
||||
setSprite(sp);
|
||||
|
||||
// shader state
|
||||
@@ -246,7 +246,7 @@ GLubyte ProgressTimer::getOpacity() const
|
||||
|
||||
void ProgressTimer::setMidpoint(const Vec2& midPoint)
|
||||
{
|
||||
_midpoint = midPoint.getClampPoint(Vec2::ZERO, Vec2(1, 1));
|
||||
_midpoint = midPoint.getClampPoint(Vec2::ZERO, Vec2::ONE);
|
||||
}
|
||||
|
||||
///
|
||||
@@ -448,20 +448,20 @@ void ProgressTimer::updateBar()
|
||||
_vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F));
|
||||
CCASSERT( _vertexData, "CCProgressTimer. Not enough memory");
|
||||
// TOPLEFT 1
|
||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Vec2(0,1));
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(Vec2(0,1));
|
||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Vec2::UNIT_Y);
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(Vec2::UNIT_Y);
|
||||
|
||||
// BOTLEFT 1
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Vec2(0,0));
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(Vec2(0,0));
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Vec2::ZERO);
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(Vec2::ZERO);
|
||||
|
||||
// TOPRIGHT 2
|
||||
_vertexData[6].texCoords = textureCoordFromAlphaPoint(Vec2(1,1));
|
||||
_vertexData[6].vertices = vertexFromAlphaPoint(Vec2(1,1));
|
||||
_vertexData[6].texCoords = textureCoordFromAlphaPoint(Vec2::ONE);
|
||||
_vertexData[6].vertices = vertexFromAlphaPoint(Vec2::ONE);
|
||||
|
||||
// BOTRIGHT 2
|
||||
_vertexData[7].texCoords = textureCoordFromAlphaPoint(Vec2(1,0));
|
||||
_vertexData[7].vertices = vertexFromAlphaPoint(Vec2(1,0));
|
||||
_vertexData[7].texCoords = textureCoordFromAlphaPoint(Vec2::UNIT_X);
|
||||
_vertexData[7].vertices = vertexFromAlphaPoint(Vec2::UNIT_X);
|
||||
}
|
||||
|
||||
// TOPRIGHT 1
|
||||
|
||||
@@ -253,7 +253,7 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
|
||||
_flippedX = _flippedY = false;
|
||||
|
||||
// default transform anchor: center
|
||||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
|
||||
// zwoptex default values
|
||||
_offsetPosition.setZero();
|
||||
|
||||
@@ -279,8 +279,8 @@ void TransitionRotoZoom:: onEnter()
|
||||
_inScene->setScale(0.001f);
|
||||
_outScene->setScale(1.0f);
|
||||
|
||||
_inScene->setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
_outScene->setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
_inScene->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
_outScene->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
|
||||
ActionInterval *rotozoom = (ActionInterval*)(Sequence::create
|
||||
(
|
||||
@@ -335,8 +335,8 @@ void TransitionJumpZoom::onEnter()
|
||||
|
||||
_inScene->setScale(0.5f);
|
||||
_inScene->setPosition(s.width, 0);
|
||||
_inScene->setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
_outScene->setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
_inScene->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
_outScene->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
|
||||
ActionInterval *jump = JumpBy::create(_duration/4, Vec2(-s.width,0), s.width/4, 2);
|
||||
ActionInterval *scaleIn = ScaleTo::create(_duration/4, 1.0f);
|
||||
@@ -403,7 +403,7 @@ void TransitionMoveInL::onEnter()
|
||||
|
||||
ActionInterval* TransitionMoveInL::action()
|
||||
{
|
||||
return MoveTo::create(_duration, Vec2(0,0));
|
||||
return MoveTo::create(_duration, Vec2::ZERO);
|
||||
}
|
||||
|
||||
ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action)
|
||||
@@ -1308,9 +1308,9 @@ void TransitionCrossFade::onEnter()
|
||||
return;
|
||||
}
|
||||
|
||||
inTexture->getSprite()->setAnchorPoint( Vec2(0.5f,0.5f) );
|
||||
inTexture->getSprite()->setAnchorPoint( Vec2::ANCHOR_MIDDLE );
|
||||
inTexture->setPosition(size.width/2, size.height/2);
|
||||
inTexture->setAnchorPoint( Vec2(0.5f,0.5f) );
|
||||
inTexture->setAnchorPoint( Vec2::ANCHOR_MIDDLE );
|
||||
|
||||
// render inScene to its texturebuffer
|
||||
inTexture->begin();
|
||||
@@ -1319,9 +1319,9 @@ void TransitionCrossFade::onEnter()
|
||||
|
||||
// create the second render texture for outScene
|
||||
RenderTexture* outTexture = RenderTexture::create((int)size.width, (int)size.height,Texture2D::PixelFormat::RGBA8888,GL_DEPTH24_STENCIL8);
|
||||
outTexture->getSprite()->setAnchorPoint( Vec2(0.5f,0.5f) );
|
||||
outTexture->getSprite()->setAnchorPoint( Vec2::ANCHOR_MIDDLE );
|
||||
outTexture->setPosition(size.width/2, size.height/2);
|
||||
outTexture->setAnchorPoint( Vec2(0.5f,0.5f) );
|
||||
outTexture->setAnchorPoint( Vec2::ANCHOR_MIDDLE );
|
||||
|
||||
// render outScene to its texturebuffer
|
||||
outTexture->begin();
|
||||
|
||||
@@ -72,9 +72,9 @@ void TransitionProgress::onEnter()
|
||||
|
||||
// create the second render texture for outScene
|
||||
RenderTexture *texture = RenderTexture::create((int)size.width, (int)size.height,Texture2D::PixelFormat::RGBA8888,GL_DEPTH24_STENCIL8);
|
||||
texture->getSprite()->setAnchorPoint(Vec2(0.5f,0.5f));
|
||||
texture->getSprite()->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
texture->setPosition(size.width/2, size.height/2);
|
||||
texture->setAnchorPoint(Vec2(0.5f,0.5f));
|
||||
texture->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
|
||||
// render outScene to its texturebuffer
|
||||
texture->beginWithClear(0, 0, 0, 1);
|
||||
@@ -145,7 +145,7 @@ ProgressTimer* TransitionProgressRadialCCW::progressTimerNodeWithRenderTexture(R
|
||||
node->setReverseDirection(false);
|
||||
node->setPercentage(100);
|
||||
node->setPosition(size.width/2, size.height/2);
|
||||
node->setAnchorPoint(Vec2(0.5f,0.5f));
|
||||
node->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
|
||||
return node;
|
||||
}
|
||||
@@ -189,7 +189,7 @@ ProgressTimer* TransitionProgressRadialCW::progressTimerNodeWithRenderTexture(Re
|
||||
node->setReverseDirection(true);
|
||||
node->setPercentage(100);
|
||||
node->setPosition(size.width/2, size.height/2);
|
||||
node->setAnchorPoint(Vec2(0.5f,0.5f));
|
||||
node->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
|
||||
return node;
|
||||
}
|
||||
@@ -217,12 +217,12 @@ ProgressTimer* TransitionProgressHorizontal::progressTimerNodeWithRenderTexture(
|
||||
node->getSprite()->setFlippedY(true);
|
||||
node->setType( ProgressTimer::Type::BAR);
|
||||
|
||||
node->setMidpoint(Vec2(1, 0));
|
||||
node->setBarChangeRate(Vec2(1,0));
|
||||
node->setMidpoint(Vec2::UNIT_X);
|
||||
node->setBarChangeRate(Vec2::UNIT_X);
|
||||
|
||||
node->setPercentage(100);
|
||||
node->setPosition(size.width/2, size.height/2);
|
||||
node->setAnchorPoint(Vec2(0.5f,0.5f));
|
||||
node->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
|
||||
return node;
|
||||
}
|
||||
@@ -250,12 +250,12 @@ ProgressTimer* TransitionProgressVertical::progressTimerNodeWithRenderTexture(Re
|
||||
node->getSprite()->setFlippedY(true);
|
||||
node->setType(ProgressTimer::Type::BAR);
|
||||
|
||||
node->setMidpoint(Vec2(0, 0));
|
||||
node->setBarChangeRate(Vec2(0,1));
|
||||
node->setMidpoint(Vec2::ZERO);
|
||||
node->setBarChangeRate(Vec2::UNIT_Y);
|
||||
|
||||
node->setPercentage(100);
|
||||
node->setPosition(size.width/2, size.height/2);
|
||||
node->setAnchorPoint(Vec2(0.5f,0.5f));
|
||||
node->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
|
||||
return node;
|
||||
}
|
||||
@@ -296,12 +296,12 @@ ProgressTimer* TransitionProgressInOut::progressTimerNodeWithRenderTexture(Rende
|
||||
node->getSprite()->setFlippedY(true);
|
||||
node->setType( ProgressTimer::Type::BAR);
|
||||
|
||||
node->setMidpoint(Vec2(0.5f, 0.5f));
|
||||
node->setBarChangeRate(Vec2(1, 1));
|
||||
node->setMidpoint(Vec2::ANCHOR_MIDDLE);
|
||||
node->setBarChangeRate(Vec2::ONE);
|
||||
|
||||
node->setPercentage(0);
|
||||
node->setPosition(size.width/2, size.height/2);
|
||||
node->setAnchorPoint(Vec2(0.5f,0.5f));
|
||||
node->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
|
||||
return node;
|
||||
}
|
||||
@@ -330,12 +330,12 @@ ProgressTimer* TransitionProgressOutIn::progressTimerNodeWithRenderTexture(Rende
|
||||
node->getSprite()->setFlippedY(true);
|
||||
node->setType( ProgressTimer::Type::BAR );
|
||||
|
||||
node->setMidpoint(Vec2(0.5f, 0.5f));
|
||||
node->setBarChangeRate(Vec2(1, 1));
|
||||
node->setMidpoint(Vec2::ANCHOR_MIDDLE);
|
||||
node->setBarChangeRate(Vec2::ONE);
|
||||
|
||||
node->setPercentage(100);
|
||||
node->setPosition(size.width/2, size.height/2);
|
||||
node->setAnchorPoint(Vec2(0.5f,0.5f));
|
||||
node->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -436,13 +436,13 @@ Rect DisplayManager::getBoundingBox() const
|
||||
|
||||
Vec2 DisplayManager::getAnchorPoint() const
|
||||
{
|
||||
CS_RETURN_IF(!_displayRenderNode) Vec2(0, 0);
|
||||
CS_RETURN_IF(!_displayRenderNode) Vec2::ANCHOR_BOTTOM_LEFT;
|
||||
return _displayRenderNode->getAnchorPoint();
|
||||
}
|
||||
|
||||
Vec2 DisplayManager::getAnchorPointInPoints() const
|
||||
{
|
||||
CS_RETURN_IF(!_displayRenderNode) Vec2(0, 0);
|
||||
CS_RETURN_IF(!_displayRenderNode) Vec2::ANCHOR_BOTTOM_LEFT;
|
||||
return _displayRenderNode->getAnchorPointInPoints();
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ ActionInterval* ActionFrame::getEasingAction(ActionInterval* action)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ActionMoveFrame::ActionMoveFrame()
|
||||
: _position(Vec2(0.0f,0.0f))
|
||||
: _position(Vec2::ZERO)
|
||||
{
|
||||
_frameType = (int)kKeyframeMove;
|
||||
}
|
||||
|
||||
@@ -857,12 +857,12 @@ _quadsDirty(true),
|
||||
_isTriangle(false),
|
||||
_isTrimmedContentSize(true),
|
||||
_fillType(Scale9SpriteV2::FillType::HORIZONTAL),
|
||||
_fillCenter(cocos2d::Vec2(0,0)),
|
||||
_fillCenter(cocos2d::Vec2::ZERO),
|
||||
_fillStart(0),
|
||||
_fillRange(0),
|
||||
_needRebuildRenderCommand(true)
|
||||
{
|
||||
this->setAnchorPoint(cocos2d::Vec2(0.5,0.5));
|
||||
this->setAnchorPoint(cocos2d::Vec2::ANCHOR_MIDDLE);
|
||||
this->setGLProgramState(cocos2d::GLProgramState::getOrCreateWithGLProgramName(cocos2d::GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ bool EditBox::initWithSizeAndBackgroundSprite(const cocos2d::Size &size, cocos2d
|
||||
_backgroundSprite = pNormal9SpriteBg;
|
||||
|
||||
this->setContentSize(size);
|
||||
this->setPosition(Vec2(0, 0));
|
||||
this->setPosition(Vec2::ZERO);
|
||||
|
||||
_backgroundSprite->setPosition(Vec2(_contentSize.width/2, _contentSize.height/2));
|
||||
_backgroundSprite->setContentSize(size);
|
||||
@@ -148,7 +148,7 @@ bool EditBox::initWithSizeAndBackgroundSprite(const Size& size,
|
||||
_backgroundSprite = Scale9Sprite::createWithSpriteFrameName(pNormal9SpriteBg);
|
||||
}
|
||||
this->setContentSize(size);
|
||||
this->setPosition(Vec2(0, 0));
|
||||
this->setPosition(Vec2::ZERO);
|
||||
|
||||
_backgroundSprite->setPosition(Vec2(_contentSize.width/2, _contentSize.height/2));
|
||||
_backgroundSprite->setContentSize(size);
|
||||
|
||||
@@ -79,13 +79,13 @@ void EditBoxImplCommon::initInactiveLabels(const Size& size)
|
||||
const char* pDefaultFontName = this->getNativeDefaultFontName();
|
||||
|
||||
_label = Label::create();
|
||||
_label->setAnchorPoint(Vec2(0, 0.5f));
|
||||
_label->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
|
||||
_label->setColor(Color3B::WHITE);
|
||||
_label->setVisible(false);
|
||||
_editBox->addChild(_label, kLabelZOrder);
|
||||
|
||||
_labelPlaceHolder = Label::create();
|
||||
_labelPlaceHolder->setAnchorPoint(Vec2(0, 0.5f));
|
||||
_labelPlaceHolder->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
|
||||
_labelPlaceHolder->setColor(Color3B::GRAY);
|
||||
_editBox->addChild(_labelPlaceHolder, kLabelZOrder);
|
||||
|
||||
|
||||
@@ -655,7 +655,7 @@ bool EditBoxImplWin::initWithSize(const Size& size)
|
||||
_label = Label::create();
|
||||
_label->setSystemFontSize(size.height-12);
|
||||
// align the text vertically center
|
||||
_label->setAnchorPoint(Vec2(0, 0.5f));
|
||||
_label->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
|
||||
_label->setPosition(Vec2(CC_EDIT_BOX_PADDING, size.height / 2.0f));
|
||||
_label->setTextColor(_colText);
|
||||
_editBox->addChild(_label);
|
||||
@@ -663,7 +663,7 @@ bool EditBoxImplWin::initWithSize(const Size& size)
|
||||
_labelPlaceHolder = Label::create();
|
||||
_labelPlaceHolder->setSystemFontSize(size.height-12);
|
||||
// align the text vertically center
|
||||
_labelPlaceHolder->setAnchorPoint(Vec2(0, 0.5f));
|
||||
_labelPlaceHolder->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
|
||||
_labelPlaceHolder->setPosition(CC_EDIT_BOX_PADDING, size.height / 2.0f);
|
||||
_labelPlaceHolder->setVisible(false);
|
||||
_labelPlaceHolder->setTextColor(_colPlaceHolder);
|
||||
|
||||
@@ -92,7 +92,7 @@ void LoadingBar::initRenderer()
|
||||
_barRenderer = Scale9Sprite::create();
|
||||
_barRenderer->setScale9Enabled(false);
|
||||
addProtectedChild(_barRenderer, BAR_RENDERER_Z, -1);
|
||||
_barRenderer->setAnchorPoint(Vec2(0.0,0.5));
|
||||
_barRenderer->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,11 +107,11 @@ void LoadingBar::setDirection(cocos2d::ui::LoadingBar::Direction direction)
|
||||
switch (_direction)
|
||||
{
|
||||
case Direction::LEFT:
|
||||
_barRenderer->setAnchorPoint(Vec2(0.0f,0.5f));
|
||||
_barRenderer->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
|
||||
_barRenderer->setPosition(Vec2(0,_contentSize.height*0.5f));
|
||||
break;
|
||||
case Direction::RIGHT:
|
||||
_barRenderer->setAnchorPoint(Vec2(1.0f,0.5f));
|
||||
_barRenderer->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT);
|
||||
_barRenderer->setPosition(Vec2(_totalLength,_contentSize.height*0.5f));
|
||||
break;
|
||||
}
|
||||
@@ -163,10 +163,10 @@ void LoadingBar::setupTexture()
|
||||
switch (_direction)
|
||||
{
|
||||
case Direction::LEFT:
|
||||
_barRenderer->setAnchorPoint(Vec2(0.0f,0.5f));
|
||||
_barRenderer->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
|
||||
break;
|
||||
case Direction::RIGHT:
|
||||
_barRenderer->setAnchorPoint(Vec2(1.0f,0.5f));
|
||||
_barRenderer->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT);
|
||||
break;
|
||||
}
|
||||
handleSpriteFlipX();
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace ui {
|
||||
,_renderingType(RenderingType::SLICE)
|
||||
,_insideBounds(true)
|
||||
{
|
||||
this->setAnchorPoint(Vec2(0.5,0.5));
|
||||
this->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
#if CC_SPRITE_DEBUG_DRAW
|
||||
_debugDrawNode = DrawNode::create();
|
||||
addChild(_debugDrawNode);
|
||||
|
||||
@@ -122,7 +122,7 @@ void Slider::initRenderer()
|
||||
_barRenderer->setScale9Enabled(false);
|
||||
_progressBarRenderer->setScale9Enabled(false);
|
||||
|
||||
_progressBarRenderer->setAnchorPoint(Vec2(0.0f, 0.5f));
|
||||
_progressBarRenderer->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
|
||||
|
||||
addProtectedChild(_barRenderer, BASEBAR_RENDERER_Z, -1);
|
||||
addProtectedChild(_progressBarRenderer, PROGRESSBAR_RENDERER_Z, -1);
|
||||
@@ -219,7 +219,7 @@ void Slider::loadProgressBarTexture(SpriteFrame* spriteframe)
|
||||
void Slider::setupProgressBarTexture()
|
||||
{
|
||||
this->updateChildrenDisplayedRGBA();
|
||||
_progressBarRenderer->setAnchorPoint(Vec2(0.0f, 0.5f));
|
||||
_progressBarRenderer->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
|
||||
_progressBarTextureSize = _progressBarRenderer->getContentSize();
|
||||
_progressBarRendererDirty = true;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ bool Widget::init()
|
||||
setBright(true);
|
||||
onFocusChanged = CC_CALLBACK_2(Widget::onFocusChange,this);
|
||||
onNextFocusedWidget = nullptr;
|
||||
this->setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
this->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
|
||||
ignoreContentAdaptWithSize(true);
|
||||
|
||||
|
||||
@@ -367,7 +367,7 @@ void ControlButton::setTitleLabelForState(Node* titleLabel, State state)
|
||||
|
||||
_titleLabelDispatchTable.insert((int)state, titleLabel);
|
||||
titleLabel->setVisible(false);
|
||||
titleLabel->setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
titleLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
addChild(titleLabel, 1);
|
||||
|
||||
// If the current state if equal to the given state we update the layout
|
||||
@@ -466,7 +466,7 @@ void ControlButton::setBackgroundSpriteForState(ui::Scale9Sprite* sprite, State
|
||||
|
||||
_backgroundSpriteDispatchTable.insert((int)state, sprite);
|
||||
sprite->setVisible(false);
|
||||
sprite->setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
addChild(sprite);
|
||||
|
||||
if (this->_preferredSize.width != 0 || this->_preferredSize.height != 0)
|
||||
|
||||
@@ -76,7 +76,7 @@ bool ControlColourPicker::init()
|
||||
_hsv.v = 0;
|
||||
|
||||
// Add image
|
||||
_background=ControlUtils::addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", spriteSheet, Vec2::ZERO, Vec2(0.5f, 0.5f));
|
||||
_background=ControlUtils::addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", spriteSheet, Vec2::ZERO, Vec2::ANCHOR_MIDDLE);
|
||||
if(!_background) return false;
|
||||
CC_SAFE_RETAIN(_background);
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ bool ControlHuePicker::initWithTargetAndPos(Node* target, Vec2 pos)
|
||||
if (Control::init())
|
||||
{
|
||||
// Add background and slider sprites
|
||||
this->setBackground(ControlUtils::addSpriteToTargetWithPosAndAnchor("huePickerBackground.png", target, pos, Vec2(0.0f, 0.0f)));
|
||||
this->setSlider(ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, Vec2(0.5f, 0.5f)));
|
||||
this->setBackground(ControlUtils::addSpriteToTargetWithPosAndAnchor("huePickerBackground.png", target, pos, Vec2::ZERO));
|
||||
this->setSlider(ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, Vec2::ANCHOR_MIDDLE));
|
||||
|
||||
_slider->setPosition(pos.x, pos.y + _background->getBoundingBox().size.height * 0.5f);
|
||||
_startPos=pos;
|
||||
|
||||
@@ -61,10 +61,10 @@ bool ControlSaturationBrightnessPicker::initWithTargetAndPos(Node* target, Vec2
|
||||
if (Control::init())
|
||||
{
|
||||
// Add background and slider sprites
|
||||
_background=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerBackground.png", target, pos, Vec2(0.0f, 0.0f));
|
||||
_overlay=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerOverlay.png", target, pos, Vec2(0.0f, 0.0f));
|
||||
_shadow=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerShadow.png", target, pos, Vec2(0.0f, 0.0f));
|
||||
_slider=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, Vec2(0.5f, 0.5f));
|
||||
_background=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerBackground.png", target, pos, Vec2::ZERO);
|
||||
_overlay=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerOverlay.png", target, pos, Vec2::ZERO);
|
||||
_shadow=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerShadow.png", target, pos, Vec2::ZERO);
|
||||
_slider=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, Vec2::ANCHOR_MIDDLE);
|
||||
|
||||
_startPos=pos; // starting position of the colour picker
|
||||
boxPos = 35; // starting position of the virtual box area for picking a colour
|
||||
|
||||
@@ -139,12 +139,12 @@ bool ControlSlider::initWithSprites(Sprite * backgroundSprite, Sprite* progressS
|
||||
setContentSize(Size(maxRect.size.width, maxRect.size.height));
|
||||
|
||||
// Add the slider background
|
||||
_backgroundSprite->setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
_backgroundSprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
_backgroundSprite->setPosition(this->getContentSize().width / 2, this->getContentSize().height / 2);
|
||||
addChild(_backgroundSprite);
|
||||
|
||||
// Add the progress bar
|
||||
_progressSprite->setAnchorPoint(Vec2(0.0f, 0.5f));
|
||||
_progressSprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
|
||||
_progressSprite->setPosition(0.0f, this->getContentSize().height / 2);
|
||||
addChild(_progressSprite);
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@ bool ControlSwitch::initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sp
|
||||
addChild(_switchSprite);
|
||||
|
||||
ignoreAnchorPointForPosition(false);
|
||||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
setContentSize(_switchSprite->getContentSize());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ bool ScrollView::initWithViewSize(Size size, Node *container/* = nullptr*/)
|
||||
{
|
||||
_container = Layer::create();
|
||||
_container->ignoreAnchorPointForPosition(false);
|
||||
_container->setAnchorPoint(Vec2(0.0f, 0.0f));
|
||||
_container->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
|
||||
}
|
||||
|
||||
this->setViewSize(size);
|
||||
@@ -348,7 +348,7 @@ void ScrollView::setContainer(Node * pContainer)
|
||||
this->_container = pContainer;
|
||||
|
||||
this->_container->ignoreAnchorPointForPosition(false);
|
||||
this->_container->setAnchorPoint(Vec2(0.0f, 0.0f));
|
||||
this->_container->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
|
||||
|
||||
this->addChild(this->_container);
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ void TableView::_updateContentSize()
|
||||
{
|
||||
if (_direction == Direction::HORIZONTAL)
|
||||
{
|
||||
this->setContentOffset(Vec2(0,0));
|
||||
this->setContentOffset(Vec2::ZERO);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -418,7 +418,7 @@ void TableView::_moveCellOutOfSight(TableViewCell *cell)
|
||||
|
||||
void TableView::_setIndexForCell(ssize_t index, TableViewCell *cell)
|
||||
{
|
||||
cell->setAnchorPoint(Vec2(0.0f, 0.0f));
|
||||
cell->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
|
||||
cell->setPosition(this->_offsetFromIndex(index));
|
||||
cell->setIdx(index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user