mirror of https://github.com/axmolengine/axmol.git
Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3
This commit is contained in:
commit
93e36001a6
3
AUTHORS
3
AUTHORS
|
@ -1107,6 +1107,9 @@ Developers:
|
|||
milos1290
|
||||
Added Lerp for Vec3
|
||||
|
||||
perminovVS
|
||||
Optimize Vec3 and Vec2
|
||||
|
||||
Retired Core Developers:
|
||||
WenSheng Yang
|
||||
Author of windows port, CCTextField,
|
||||
|
|
|
@ -3,6 +3,7 @@ cocos2d-x-3.6 ??
|
|||
[NEW] 3rd: update freetype to v 2.5.5 on Windows 8.1 Universal App
|
||||
[NEW] Label: added LabelEffect::ALL which can be used in disableEffect(LabelEffect) to disable all effects
|
||||
[NEW] MathUtil: added `MathUtil::lerp()`
|
||||
[NEW] Vec2: added `Vec2::setZero()`
|
||||
[NEW] Vec3: added `Vec3::lerp()`
|
||||
[NEW] WP8: remove WP8 support because Angle don't support WP8 any more
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ bool Follow::initWithTarget(Node *followedNode, const Rect& rect/* = Rect::ZERO*
|
|||
_boundaryFullyCovered = false;
|
||||
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
_fullScreenSize = Vec2(winSize.width, winSize.height);
|
||||
_fullScreenSize.set(winSize.width, winSize.height);
|
||||
_halfScreenSize = _fullScreenSize * 0.5f;
|
||||
|
||||
if (_boundarySet)
|
||||
|
|
|
@ -96,7 +96,7 @@ void ActionCamera::updateTransform()
|
|||
|
||||
Vec2 anchorPoint = _target->getAnchorPointInPoints();
|
||||
|
||||
bool needsTranslation = !anchorPoint.equals(Vec2::ZERO);
|
||||
bool needsTranslation = !anchorPoint.isZero();
|
||||
|
||||
Mat4 mv = Mat4::IDENTITY;
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ void CardinalSplineTo::startWithTarget(cocos2d::Node *target)
|
|||
_deltaT = (float) 1 / (_points->count() - 1);
|
||||
|
||||
_previousPosition = target->getPosition();
|
||||
_accumulatedDiff = Vec2::ZERO;
|
||||
_accumulatedDiff.setZero();
|
||||
}
|
||||
|
||||
CardinalSplineTo* CardinalSplineTo::clone() const
|
||||
|
|
|
@ -143,8 +143,8 @@ void FlipX3D::update(float time)
|
|||
|
||||
Vec3 v0, v1, v, diff;
|
||||
|
||||
v0 = getOriginalVertex(Vec2(1, 1));
|
||||
v1 = getOriginalVertex(Vec2(0, 0));
|
||||
v0 = getOriginalVertex(Vec2(1.0f, 1.0f));
|
||||
v1 = getOriginalVertex(Vec2());
|
||||
|
||||
float x0 = v0.x;
|
||||
float x1 = v1.x;
|
||||
|
@ -154,19 +154,19 @@ void FlipX3D::update(float time)
|
|||
if ( x0 > x1 )
|
||||
{
|
||||
// Normal Grid
|
||||
a = Vec2(0,0);
|
||||
b = Vec2(0,1);
|
||||
c = Vec2(1,0);
|
||||
d = Vec2(1,1);
|
||||
a.setZero();
|
||||
b.set(0.0f, 1.0f);
|
||||
c.set(1.0f, 0.0f);
|
||||
d.set(1.0f, 1.0f);
|
||||
x = x0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reversed Grid
|
||||
c = Vec2(0,0);
|
||||
d = Vec2(0,1);
|
||||
a = Vec2(1,0);
|
||||
b = Vec2(1,1);
|
||||
c.setZero();
|
||||
d.set(0.0f, 1.0f);
|
||||
a.set(1.0f, 0.0f);
|
||||
b.set(1.0f, 1.0f);
|
||||
x = x1;
|
||||
}
|
||||
|
||||
|
@ -237,8 +237,8 @@ void FlipY3D::update(float time)
|
|||
|
||||
Vec3 v0, v1, v, diff;
|
||||
|
||||
v0 = getOriginalVertex(Vec2(1, 1));
|
||||
v1 = getOriginalVertex(Vec2(0, 0));
|
||||
v0 = getOriginalVertex(Vec2(1.0f, 1.0f));
|
||||
v1 = getOriginalVertex(Vec2());
|
||||
|
||||
float y0 = v0.y;
|
||||
float y1 = v1.y;
|
||||
|
@ -248,19 +248,19 @@ void FlipY3D::update(float time)
|
|||
if (y0 > y1)
|
||||
{
|
||||
// Normal Grid
|
||||
a = Vec2(0,0);
|
||||
b = Vec2(0,1);
|
||||
c = Vec2(1,0);
|
||||
d = Vec2(1,1);
|
||||
a.setZero();
|
||||
b.set(0.0f, 1.0f);
|
||||
c.set(1.0f, 0.0f);
|
||||
d.set(1.0f, 1.0f);
|
||||
y = y0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reversed Grid
|
||||
b = Vec2(0,0);
|
||||
a = Vec2(0,1);
|
||||
d = Vec2(1,0);
|
||||
c = Vec2(1,1);
|
||||
b.setZero();
|
||||
a.set(0.0f, 1.0f);
|
||||
d.set(1.0f, 0.0f);
|
||||
c.set(1.0f, 1.0f);
|
||||
y = y1;
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,7 @@ bool Lens3D::initWithDuration(float duration, const Size& gridSize, const Vec2&
|
|||
{
|
||||
if (Grid3DAction::initWithDuration(duration, gridSize))
|
||||
{
|
||||
_position = Vec2(-1, -1);
|
||||
_position.set(-1.0f, -1.0f);
|
||||
setPosition(position);
|
||||
_radius = radius;
|
||||
_lensEffect = 0.7f;
|
||||
|
@ -725,13 +725,13 @@ void Twirl::update(float time)
|
|||
{
|
||||
Vec3 v = getOriginalVertex(Vec2(i ,j));
|
||||
|
||||
Vec2 avg = Vec2(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f));
|
||||
Vec2 avg(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f));
|
||||
float r = avg.getLength();
|
||||
|
||||
float amp = 0.1f * _amplitude * _amplitudeRate;
|
||||
float a = r * cosf( (float)M_PI/2.0f + time * (float)M_PI * _twirls * 2 ) * amp;
|
||||
|
||||
Vec2 d = Vec2(
|
||||
Vec2 d(
|
||||
sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x),
|
||||
cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x));
|
||||
|
||||
|
|
|
@ -1478,7 +1478,7 @@ JumpTo* JumpTo::reverse() const
|
|||
void JumpTo::startWithTarget(Node *target)
|
||||
{
|
||||
JumpBy::startWithTarget(target);
|
||||
_delta = Vec2(_endPosition.x - _startPosition.x, _endPosition.y - _startPosition.y);
|
||||
_delta.set(_endPosition.x - _startPosition.x, _endPosition.y - _startPosition.y);
|
||||
}
|
||||
|
||||
// Bezier cubic formula:
|
||||
|
|
|
@ -325,8 +325,8 @@ void ShuffleTiles::startWithTarget(Node *target)
|
|||
{
|
||||
for ( int j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
tileArray->position = Vec2((float)i, (float)j);
|
||||
tileArray->startPosition = Vec2((float)i, (float)j);
|
||||
tileArray->position.set((float)i, (float)j);
|
||||
tileArray->startPosition.set((float)i, (float)j);
|
||||
tileArray->delta = getDelta(Size(i, j));
|
||||
++tileArray;
|
||||
}
|
||||
|
@ -694,7 +694,7 @@ void TurnOffTiles::update(float time)
|
|||
for (unsigned int i = 0; i < _tilesCount; i++ )
|
||||
{
|
||||
t = _tilesOrder[i];
|
||||
Vec2 tilePos = Vec2( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height );
|
||||
Vec2 tilePos( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height );
|
||||
|
||||
if ( i < l )
|
||||
{
|
||||
|
|
|
@ -202,10 +202,10 @@ void ClippingNode::drawFullScreenQuadClearStencil()
|
|||
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
|
||||
Vec2 vertices[] = {
|
||||
Vec2(-1, -1),
|
||||
Vec2(1, -1),
|
||||
Vec2(1, 1),
|
||||
Vec2(-1, 1)
|
||||
Vec2(-1.0f, -1.0f),
|
||||
Vec2(1.0f, -1.0f),
|
||||
Vec2(1.0f, 1.0f),
|
||||
Vec2(-1.0f, 1.0f)
|
||||
};
|
||||
|
||||
auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR);
|
||||
|
|
|
@ -328,7 +328,7 @@ void drawSolidPoly(const Vec2 *poli, unsigned int numberOfPoints, Color4F color)
|
|||
// Mac on 64-bit
|
||||
for(unsigned int i = 0; i < numberOfPoints; i++)
|
||||
{
|
||||
newPoli[i] = Vec2( poli[i].x, poli[i].y );
|
||||
newPoli[i].set(poli[i].x, poli[i].y);
|
||||
}
|
||||
#ifdef EMSCRIPTEN
|
||||
setGLBufferData(newPoli, numberOfPoints * sizeof(Vec2));
|
||||
|
|
|
@ -740,19 +740,19 @@ void TMXLayer::parseInternalProperties()
|
|||
//CCTMXLayer2 - obtaining positions, offset
|
||||
Vec2 TMXLayer::calculateLayerOffset(const Vec2& pos)
|
||||
{
|
||||
Vec2 ret = Vec2::ZERO;
|
||||
Vec2 ret;
|
||||
switch (_layerOrientation)
|
||||
{
|
||||
case FAST_TMX_ORIENTATION_ORTHO:
|
||||
ret = Vec2( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height);
|
||||
ret.set( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height);
|
||||
break;
|
||||
case FAST_TMX_ORIENTATION_ISO:
|
||||
ret = Vec2((_mapTileSize.width /2) * (pos.x - pos.y),
|
||||
ret.set((_mapTileSize.width /2) * (pos.x - pos.y),
|
||||
(_mapTileSize.height /2 ) * (-pos.x - pos.y));
|
||||
break;
|
||||
case FAST_TMX_ORIENTATION_HEX:
|
||||
default:
|
||||
CCASSERT(pos.equals(Vec2::ZERO), "offset for this map not implemented yet");
|
||||
CCASSERT(pos.isZero(), "offset for this map not implemented yet");
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -714,7 +714,7 @@ void LayerGradient::updateColor()
|
|||
return;
|
||||
|
||||
float c = sqrtf(2.0f);
|
||||
Vec2 u = Vec2(_alongVector.x / h, _alongVector.y / h);
|
||||
Vec2 u(_alongVector.x / h, _alongVector.y / h);
|
||||
|
||||
// Compressed Interpolation mode
|
||||
if (_compressedInterpolation)
|
||||
|
|
|
@ -549,7 +549,7 @@ MenuItem* Menu::getItemForTouch(Touch *touch)
|
|||
{
|
||||
Vec2 local = child->convertToNodeSpace(touchLocation);
|
||||
Rect r = child->rect();
|
||||
r.origin = Vec2::ZERO;
|
||||
r.origin.setZero();
|
||||
|
||||
if (r.containsPoint(local))
|
||||
{
|
||||
|
|
|
@ -40,7 +40,6 @@ MotionStreak::MotionStreak()
|
|||
, _startingPositionInitialized(false)
|
||||
, _texture(nullptr)
|
||||
, _blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED)
|
||||
, _positionR(Vec2::ZERO)
|
||||
, _stroke(0.0f)
|
||||
, _fadeDelta(0.0f)
|
||||
, _minSeg(0.0f)
|
||||
|
@ -106,7 +105,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
|
|||
ignoreAnchorPointForPosition(true);
|
||||
_startingPositionInitialized = false;
|
||||
|
||||
_positionR = Vec2::ZERO;
|
||||
_positionR.setZero();
|
||||
_fastMode = true;
|
||||
_minSeg = (minSeg == -1.0f) ? stroke/5.0f : minSeg;
|
||||
_minSeg *= _minSeg;
|
||||
|
|
|
@ -83,14 +83,11 @@ Node::Node(void)
|
|||
, _scaleX(1.0f)
|
||||
, _scaleY(1.0f)
|
||||
, _scaleZ(1.0f)
|
||||
, _position(Vec2::ZERO)
|
||||
, _positionZ(0.0f)
|
||||
, _usingNormalizedPosition(false)
|
||||
, _normalizedPositionDirty(false)
|
||||
, _skewX(0.0f)
|
||||
, _skewY(0.0f)
|
||||
, _anchorPointInPoints(Vec2::ZERO)
|
||||
, _anchorPoint(Vec2::ZERO)
|
||||
, _contentSize(Size::ZERO)
|
||||
, _contentSizeDirty(true)
|
||||
, _transformDirty(true)
|
||||
|
@ -723,7 +720,7 @@ void Node::setAnchorPoint(const Vec2& point)
|
|||
if (! point.equals(_anchorPoint))
|
||||
{
|
||||
_anchorPoint = point;
|
||||
_anchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y);
|
||||
_anchorPointInPoints.set(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y);
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
}
|
||||
|
@ -740,7 +737,7 @@ void Node::setContentSize(const Size & size)
|
|||
{
|
||||
_contentSize = size;
|
||||
|
||||
_anchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y);
|
||||
_anchorPointInPoints.set(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y);
|
||||
_transformUpdated = _transformDirty = _inverseDirty = _contentSizeDirty = true;
|
||||
}
|
||||
}
|
||||
|
@ -1768,7 +1765,7 @@ const Mat4& Node::getNodeToParentTransform() const
|
|||
Vec2 anchorPoint(_anchorPointInPoints.x * _scaleX, _anchorPointInPoints.y * _scaleY);
|
||||
|
||||
// caculate real position
|
||||
if (! needsSkewMatrix && !_anchorPointInPoints.equals(Vec2::ZERO))
|
||||
if (! needsSkewMatrix && !_anchorPointInPoints.isZero())
|
||||
{
|
||||
x += -anchorPoint.x;
|
||||
y += -anchorPoint.y;
|
||||
|
@ -1831,7 +1828,7 @@ const Mat4& Node::getNodeToParentTransform() const
|
|||
_transform = _transform * skewMatrix;
|
||||
|
||||
// adjust anchor point
|
||||
if (!_anchorPointInPoints.equals(Vec2::ZERO))
|
||||
if (!_anchorPointInPoints.isZero())
|
||||
{
|
||||
// FIXME:: Argh, Mat4 needs a "translate" method.
|
||||
// FIXME:: Although this is faster than multiplying a vec4 * mat4
|
||||
|
|
|
@ -66,7 +66,7 @@ private:
|
|||
ParallaxNode::ParallaxNode()
|
||||
{
|
||||
_parallaxArray = ccArrayNew(5);
|
||||
_lastPosition = Vec2(-100,-100);
|
||||
_lastPosition.set(-100.0f, -100.0f);
|
||||
}
|
||||
|
||||
ParallaxNode::~ParallaxNode()
|
||||
|
|
|
@ -98,7 +98,7 @@ bool ParticleFire::initWithTotalParticles(int numberOfParticles)
|
|||
this->_emitterMode = Mode::GRAVITY;
|
||||
|
||||
// Gravity Mode: gravity
|
||||
this->modeA.gravity = Vec2(0,0);
|
||||
this->modeA.gravity.setZero();
|
||||
|
||||
// Gravity Mode: radial acceleration
|
||||
this->modeA.radialAccel = 0;
|
||||
|
@ -114,8 +114,8 @@ bool ParticleFire::initWithTotalParticles(int numberOfParticles)
|
|||
|
||||
// emitter position
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(winSize.width/2, 60);
|
||||
this->_posVar = Vec2(40, 20);
|
||||
this->setPosition(winSize.width/2.0f, 60.0f);
|
||||
this->_posVar.set(40.0f, 20.0f);
|
||||
|
||||
// life of particles
|
||||
_life = 3;
|
||||
|
@ -203,27 +203,27 @@ bool ParticleFireworks::initWithTotalParticles(int numberOfParticles)
|
|||
this->_emitterMode = Mode::GRAVITY;
|
||||
|
||||
// Gravity Mode: gravity
|
||||
this->modeA.gravity = Vec2(0,-90);
|
||||
this->modeA.gravity.set(0.0f, -90.0f);
|
||||
|
||||
// Gravity Mode: radial
|
||||
this->modeA.radialAccel = 0;
|
||||
this->modeA.radialAccelVar = 0;
|
||||
this->modeA.radialAccel = 0.0f;
|
||||
this->modeA.radialAccelVar = 0.0f;
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
this->modeA.speed = 180;
|
||||
this->modeA.speedVar = 50;
|
||||
this->modeA.speed = 180.0f;
|
||||
this->modeA.speedVar = 50.0f;
|
||||
|
||||
// emitter position
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(winSize.width/2, winSize.height/2);
|
||||
|
||||
// angle
|
||||
this->_angle= 90;
|
||||
this->_angleVar = 20;
|
||||
this->_angle= 90.0f;
|
||||
this->_angleVar = 20.0f;
|
||||
|
||||
// life of particles
|
||||
this->_life = 3.5f;
|
||||
this->_lifeVar = 1;
|
||||
this->_lifeVar = 1.0f;
|
||||
|
||||
// emits per frame
|
||||
this->_emissionRate = _totalParticles/_life;
|
||||
|
|
|
@ -93,8 +93,6 @@ ParticleSystem::ParticleSystem()
|
|||
, _isActive(true)
|
||||
, _particleCount(0)
|
||||
, _duration(0)
|
||||
, _sourcePosition(Vec2::ZERO)
|
||||
, _posVar(Vec2::ZERO)
|
||||
, _life(0)
|
||||
, _lifeVar(0)
|
||||
, _angle(0)
|
||||
|
@ -116,7 +114,7 @@ ParticleSystem::ParticleSystem()
|
|||
, _yCoordFlipped(1)
|
||||
, _positionType(PositionType::FREE)
|
||||
{
|
||||
modeA.gravity = Vec2::ZERO;
|
||||
modeA.gravity.setZero();
|
||||
modeA.speed = 0;
|
||||
modeA.speedVar = 0;
|
||||
modeA.tangentialAccel = 0;
|
||||
|
@ -683,7 +681,7 @@ void ParticleSystem::update(float dt)
|
|||
|
||||
_particleIdx = 0;
|
||||
|
||||
Vec2 currentPosition = Vec2::ZERO;
|
||||
Vec2 currentPosition;
|
||||
if (_positionType == PositionType::FREE)
|
||||
{
|
||||
currentPosition = this->convertToWorldSpace(Vec2::ZERO);
|
||||
|
@ -710,7 +708,6 @@ void ParticleSystem::update(float dt)
|
|||
{
|
||||
Vec2 tmp, radial, tangential;
|
||||
|
||||
radial = Vec2::ZERO;
|
||||
// radial acceleration
|
||||
if (p->pos.x || p->pos.y)
|
||||
{
|
||||
|
|
|
@ -237,7 +237,7 @@ void ParticleSystemQuad::setTexture(Texture2D* texture)
|
|||
|
||||
void ParticleSystemQuad::setDisplayFrame(SpriteFrame *spriteFrame)
|
||||
{
|
||||
CCASSERT(spriteFrame->getOffsetInPixels().equals(Vec2::ZERO),
|
||||
CCASSERT(spriteFrame->getOffsetInPixels().isZero(),
|
||||
"QuadParticle only supports SpriteFrames with no offsets");
|
||||
|
||||
// update texture before updating texture rect
|
||||
|
|
|
@ -157,8 +157,8 @@ Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vec2 alpha)
|
|||
return ret;
|
||||
}
|
||||
V3F_C4B_T2F_Quad quad = _sprite->getQuad();
|
||||
Vec2 min = Vec2(quad.bl.texCoords.u,quad.bl.texCoords.v);
|
||||
Vec2 max = Vec2(quad.tr.texCoords.u,quad.tr.texCoords.v);
|
||||
Vec2 min(quad.bl.texCoords.u,quad.bl.texCoords.v);
|
||||
Vec2 max(quad.tr.texCoords.u,quad.tr.texCoords.v);
|
||||
// Fix bug #1303 so that progress timer handles sprite frame texture rotation
|
||||
if (_sprite->isTextureRectRotated()) {
|
||||
std::swap(alpha.x, alpha.y);
|
||||
|
@ -173,8 +173,8 @@ Vec2 ProgressTimer::vertexFromAlphaPoint(Vec2 alpha)
|
|||
return ret;
|
||||
}
|
||||
V3F_C4B_T2F_Quad quad = _sprite->getQuad();
|
||||
Vec2 min = Vec2(quad.bl.vertices.x,quad.bl.vertices.y);
|
||||
Vec2 max = Vec2(quad.tr.vertices.x,quad.tr.vertices.y);
|
||||
Vec2 min(quad.bl.vertices.x,quad.bl.vertices.y);
|
||||
Vec2 max(quad.tr.vertices.x,quad.tr.vertices.y);
|
||||
ret.x = min.x * (1.f - alpha.x) + max.x * alpha.x;
|
||||
ret.y = min.y * (1.f - alpha.y) + max.y * alpha.y;
|
||||
return ret;
|
||||
|
@ -269,12 +269,12 @@ void ProgressTimer::updateRadial(void)
|
|||
// We find the vector to do a hit detection based on the percentage
|
||||
// We know the first vector is the one @ 12 o'clock (top,mid) so we rotate
|
||||
// from that by the progress angle around the _midpoint pivot
|
||||
Vec2 topMid = Vec2(_midpoint.x, 1.f);
|
||||
Vec2 topMid(_midpoint.x, 1.f);
|
||||
Vec2 percentagePt = topMid.rotateByAngle(_midpoint, angle);
|
||||
|
||||
|
||||
int index = 0;
|
||||
Vec2 hit = Vec2::ZERO;
|
||||
Vec2 hit;
|
||||
|
||||
if (alpha == 0.f) {
|
||||
// More efficient since we don't always need to check intersection
|
||||
|
|
|
@ -228,7 +228,7 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
|
|||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
|
||||
// zwoptex default values
|
||||
_offsetPosition = Vec2::ZERO;
|
||||
_offsetPosition.setZero();
|
||||
|
||||
// clean the Quad
|
||||
memset(&_quad, 0, sizeof(_quad));
|
||||
|
|
|
@ -605,18 +605,18 @@ void TMXLayer::removeTileAt(const Vec2& pos)
|
|||
//CCTMXLayer - obtaining positions, offset
|
||||
Vec2 TMXLayer::calculateLayerOffset(const Vec2& pos)
|
||||
{
|
||||
Vec2 ret = Vec2::ZERO;
|
||||
Vec2 ret;
|
||||
switch (_layerOrientation)
|
||||
{
|
||||
case TMXOrientationOrtho:
|
||||
ret = Vec2( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height);
|
||||
ret.set( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height);
|
||||
break;
|
||||
case TMXOrientationIso:
|
||||
ret = Vec2((_mapTileSize.width /2) * (pos.x - pos.y),
|
||||
ret.set((_mapTileSize.width /2) * (pos.x - pos.y),
|
||||
(_mapTileSize.height /2 ) * (-pos.x - pos.y));
|
||||
break;
|
||||
case TMXOrientationHex:
|
||||
CCASSERT(pos.equals(Vec2::ZERO), "offset for hexagonal map not implemented yet");
|
||||
CCASSERT(pos.isZero(), "offset for hexagonal map not implemented yet");
|
||||
break;
|
||||
case TMXOrientationStaggered:
|
||||
{
|
||||
|
@ -625,7 +625,7 @@ Vec2 TMXLayer::calculateLayerOffset(const Vec2& pos)
|
|||
{
|
||||
diffX = _mapTileSize.width/2;
|
||||
}
|
||||
ret = Vec2(pos.x * _mapTileSize.width + diffX,
|
||||
ret.set(pos.x * _mapTileSize.width + diffX,
|
||||
(-pos.y) * _mapTileSize.height/2);
|
||||
}
|
||||
break;
|
||||
|
@ -635,7 +635,7 @@ Vec2 TMXLayer::calculateLayerOffset(const Vec2& pos)
|
|||
|
||||
Vec2 TMXLayer::getPositionAt(const Vec2& pos)
|
||||
{
|
||||
Vec2 ret = Vec2::ZERO;
|
||||
Vec2 ret;
|
||||
switch (_layerOrientation)
|
||||
{
|
||||
case TMXOrientationOrtho:
|
||||
|
@ -675,7 +675,8 @@ Vec2 TMXLayer::getPositionForHexAt(const Vec2& pos)
|
|||
diffY = -_mapTileSize.height/2 ;
|
||||
}
|
||||
|
||||
Vec2 xy = Vec2(pos.x * _mapTileSize.width*3/4,
|
||||
Vec2 xy(
|
||||
pos.x * _mapTileSize.width*3/4,
|
||||
(_layerSize.height - pos.y - 1) * _mapTileSize.height + diffY);
|
||||
return xy;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ NS_CC_BEGIN
|
|||
|
||||
TMXObjectGroup::TMXObjectGroup()
|
||||
: _groupName("")
|
||||
, _positionOffset(Vec2::ZERO)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ TMXLayerInfo::TMXLayerInfo()
|
|||
: _name("")
|
||||
, _tiles(nullptr)
|
||||
, _ownTiles(true)
|
||||
, _offset(Vec2::ZERO)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -355,7 +354,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
|
||||
float x = attributeDict["x"].asFloat();
|
||||
float y = attributeDict["y"].asFloat();
|
||||
layer->_offset = Vec2(x,y);
|
||||
layer->_offset.set(x, y);
|
||||
|
||||
tmxMapInfo->getLayers().pushBack(layer);
|
||||
layer->release();
|
||||
|
|
|
@ -297,19 +297,19 @@ void Terrain::setChunksLOD(Vec3 cameraPos)
|
|||
|
||||
float Terrain::getHeight(float x, float z, Vec3 * normal)
|
||||
{
|
||||
Vec2 pos = Vec2(x,z);
|
||||
Vec2 pos(x,z);
|
||||
|
||||
//top-left
|
||||
Vec2 tl = Vec2(-1*_terrainData._mapScale*_imageWidth/2,-1*_terrainData._mapScale*_imageHeight/2);
|
||||
Vec2 tl(-1*_terrainData._mapScale*_imageWidth/2,-1*_terrainData._mapScale*_imageHeight/2);
|
||||
auto result = getNodeToWorldTransform()*Vec4(tl.x,0.0f,tl.y,1.0f);
|
||||
tl = Vec2(result.x,result.z);
|
||||
tl.set(result.x, result.z);
|
||||
|
||||
Vec2 to_tl = pos - tl;
|
||||
|
||||
//real size
|
||||
Vec2 size = Vec2(_imageWidth*_terrainData._mapScale,_imageHeight*_terrainData._mapScale);
|
||||
Vec2 size(_imageWidth*_terrainData._mapScale,_imageHeight*_terrainData._mapScale);
|
||||
result = getNodeToWorldTransform()*Vec4(size.x,0.0f,size.y,0.0f);
|
||||
size = Vec2(result.x,result.z);
|
||||
size.set(result.x, result.z);
|
||||
|
||||
float width_ratio = to_tl.x/size.x;
|
||||
float height_ratio = to_tl.y/size.y;
|
||||
|
@ -543,19 +543,19 @@ void Terrain::setMaxDetailMapAmount(int max_value)
|
|||
|
||||
cocos2d::Vec2 Terrain::convertToTerrainSpace(Vec2 worldSpaceXZ)
|
||||
{
|
||||
Vec2 pos = Vec2(worldSpaceXZ.x,worldSpaceXZ.y);
|
||||
Vec2 pos(worldSpaceXZ.x,worldSpaceXZ.y);
|
||||
|
||||
//top-left
|
||||
Vec2 tl = Vec2(-1*_terrainData._mapScale*_imageWidth/2,-1*_terrainData._mapScale*_imageHeight/2);
|
||||
Vec2 tl(-1*_terrainData._mapScale*_imageWidth/2,-1*_terrainData._mapScale*_imageHeight/2);
|
||||
auto result = getNodeToWorldTransform()*Vec4(tl.x,0.0f,tl.y,1.0f);
|
||||
tl = Vec2(result.x,result.z);
|
||||
tl.set(result.x, result.z);
|
||||
|
||||
Vec2 to_tl = pos - tl;
|
||||
|
||||
//real size
|
||||
Vec2 size = Vec2(_imageWidth*_terrainData._mapScale,_imageHeight*_terrainData._mapScale);
|
||||
Vec2 size(_imageWidth*_terrainData._mapScale,_imageHeight*_terrainData._mapScale);
|
||||
result = getNodeToWorldTransform()*Vec4(size.x,0.0f,size.y,0.0f);
|
||||
size = Vec2(result.x,result.z);
|
||||
size.set(result.x, result.z);
|
||||
|
||||
float width_ratio = to_tl.x/size.x;
|
||||
float height_ratio = to_tl.y/size.y;
|
||||
|
@ -1206,8 +1206,8 @@ void Terrain::Chunk::calculateSlope()
|
|||
highest = _originalVertices[i]._position;
|
||||
}
|
||||
}
|
||||
auto a = Vec2(lowest.x,lowest.z);
|
||||
auto b = Vec2(highest.x,highest.z);
|
||||
Vec2 a(lowest.x,lowest.z);
|
||||
Vec2 b(highest.x,highest.z);
|
||||
float dist = a.distance(b);
|
||||
_slope = (highest.y - lowest.y)/dist;
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ Rect RectFromString(const std::string& str)
|
|||
|
||||
Vec2 PointFromString(const std::string& str)
|
||||
{
|
||||
Vec2 ret = Vec2::ZERO;
|
||||
Vec2 ret;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -158,7 +158,7 @@ Vec2 PointFromString(const std::string& str)
|
|||
float x = (float) utils::atof(strs[0].c_str());
|
||||
float y = (float) utils::atof(strs[1].c_str());
|
||||
|
||||
ret = Vec2(x, y);
|
||||
ret.set(x, y);
|
||||
} while (0);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
const Vec2 CCPointZero = Vec2::ZERO;
|
||||
const Vec2 CCPointZero;
|
||||
|
||||
/* The "zero" size -- equivalent to Size(0, 0). */
|
||||
const Size CCSizeZero = Size::ZERO;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace cocosbuilder {
|
|||
|
||||
CC_DLL Vec2 getAbsolutePosition(const Vec2 &pt, CCBReader::PositionType type, const Size &containerSize, const std::string& propName)
|
||||
{
|
||||
Vec2 absPt = Vec2(0,0);
|
||||
Vec2 absPt;
|
||||
if (type == CCBReader::PositionType::RELATIVE_BOTTOM_LEFT)
|
||||
{
|
||||
absPt = pt;
|
||||
|
|
|
@ -329,7 +329,7 @@ void Armature::updateOffsetPoint()
|
|||
// Set contentsize and Calculate anchor point.
|
||||
Rect rect = getBoundingBox();
|
||||
setContentSize(rect.size);
|
||||
_offsetPoint = Vec2(-rect.origin.x, -rect.origin.y);
|
||||
_offsetPoint.set(-rect.origin.x, -rect.origin.y);
|
||||
if (rect.size.width != 0 && rect.size.height != 0)
|
||||
{
|
||||
setAnchorPoint(Vec2(_offsetPoint.x / rect.size.width, _offsetPoint.y / rect.size.height));
|
||||
|
@ -341,8 +341,8 @@ void Armature::setAnchorPoint(const Vec2& point)
|
|||
if( ! point.equals(_anchorPoint))
|
||||
{
|
||||
_anchorPoint = point;
|
||||
_anchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x - _offsetPoint.x, _contentSize.height * _anchorPoint.y - _offsetPoint.y);
|
||||
_realAnchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y);
|
||||
_anchorPointInPoints.set(_contentSize.width * _anchorPoint.x - _offsetPoint.x, _contentSize.height * _anchorPoint.y - _offsetPoint.y);
|
||||
_realAnchorPointInPoints.set(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y);
|
||||
_transformDirty = _inverseDirty = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -380,7 +380,7 @@ bool DisplayManager::containPoint(Vec2 &point)
|
|||
*
|
||||
*/
|
||||
|
||||
Vec2 outPoint = Vec2(0, 0);
|
||||
Vec2 outPoint;
|
||||
|
||||
Sprite *sprite = (Sprite *)_currentDecoDisplay->getDisplay();
|
||||
sprite = (Sprite *)sprite->getChildByTag(0);
|
||||
|
@ -398,7 +398,7 @@ bool DisplayManager::containPoint(Vec2 &point)
|
|||
|
||||
bool DisplayManager::containPoint(float x, float y)
|
||||
{
|
||||
Vec2 p = Vec2(x, y);
|
||||
Vec2 p(x, y);
|
||||
return containPoint(p);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ bool isSpriteContainPoint(Sprite *sprite, Vec2 point, Vec2 &outPoint)
|
|||
|
||||
bool isSpriteContainPoint(Sprite *sprite, Vec2 point)
|
||||
{
|
||||
Vec2 p = Vec2(0, 0);
|
||||
Vec2 p;
|
||||
return isSpriteContainPoint(sprite, point, p);
|
||||
}
|
||||
|
||||
|
|
|
@ -1173,7 +1173,7 @@ flatbuffers::Offset<flatbuffers::EasingData> FlatBuffersSerialize::createEasingD
|
|||
const tinyxml2::XMLElement* PointF = Points->FirstChildElement();
|
||||
while (PointF)
|
||||
{
|
||||
Vec2 pointF = Vec2::ZERO;
|
||||
Vec2 pointF;
|
||||
|
||||
attribute = PointF->FirstAttribute();
|
||||
|
||||
|
|
|
@ -89,17 +89,17 @@ namespace cocostudio
|
|||
{
|
||||
std::string name = "";
|
||||
long actionTag = 0;
|
||||
Vec2 rotationSkew = Vec2::ZERO;
|
||||
Vec2 rotationSkew;
|
||||
int zOrder = 0;
|
||||
bool visible = true;
|
||||
GLubyte alpha = 255;
|
||||
int tag = 0;
|
||||
Vec2 position = Vec2::ZERO;
|
||||
Vec2 scale = Vec2(1.0f, 1.0f);
|
||||
Vec2 anchorPoint = Vec2::ZERO;
|
||||
Vec2 position;
|
||||
Vec2 scale(1.0f, 1.0f);
|
||||
Vec2 anchorPoint;
|
||||
Color4B color(255, 255, 255, 255);
|
||||
|
||||
Vec2 size = Vec2::ZERO;
|
||||
Vec2 size;
|
||||
bool flipX = false;
|
||||
bool flipY = false;
|
||||
bool ignoreSize = false;
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace cocostudio
|
|||
if(!attribute)
|
||||
return Vec2::ZERO;
|
||||
|
||||
Vec2 ret(Vec2::ZERO);
|
||||
Vec2 ret;
|
||||
std::string attriname;
|
||||
|
||||
while (attribute)
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace cocostudio
|
|||
if(!attribute)
|
||||
return Vec2::ZERO;
|
||||
|
||||
Vec2 ret(Vec2::ZERO);
|
||||
Vec2 ret;
|
||||
std::string attriname;
|
||||
|
||||
while (attribute)
|
||||
|
|
|
@ -391,16 +391,16 @@ namespace cocostudio
|
|||
{
|
||||
std::string name = "";
|
||||
long actionTag = 0;
|
||||
Vec2 rotationSkew = Vec2::ZERO;
|
||||
Vec2 rotationSkew;
|
||||
int zOrder = 0;
|
||||
bool visible = true;
|
||||
GLubyte alpha = 255;
|
||||
int tag = 0;
|
||||
Vec2 position = Vec2::ZERO;
|
||||
Vec2 scale = Vec2(1.0f, 1.0f);
|
||||
Vec2 anchorPoint = Vec2::ZERO;
|
||||
Vec2 position;
|
||||
Vec2 scale(1.0f, 1.0f);
|
||||
Vec2 anchorPoint;
|
||||
Color4B color(255, 255, 255, 255);
|
||||
Vec2 size = Vec2::ZERO;
|
||||
Vec2 size;
|
||||
bool flipX = false;
|
||||
bool flipY = false;
|
||||
bool ignoreSize = false;
|
||||
|
|
|
@ -69,8 +69,8 @@ void ccVertexLineToPolygon(Vec2 *points, float stroke, Vec2 *vertices, unsigned
|
|||
}
|
||||
perpVector = perpVector * stroke;
|
||||
|
||||
vertices[idx] = Vec2(p1.x+perpVector.x, p1.y+perpVector.y);
|
||||
vertices[idx+1] = Vec2(p1.x-perpVector.x, p1.y-perpVector.y);
|
||||
vertices[idx].set(p1.x + perpVector.x, p1.y + perpVector.y);
|
||||
vertices[idx + 1].set(p1.x - perpVector.x, p1.y - perpVector.y);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -67,57 +67,12 @@ float crossProduct2Vector(const Vec2& A, const Vec2& B, const Vec2& C, const Vec
|
|||
return (D.y - C.y) * (B.x - A.x) - (D.x - C.x) * (B.y - A.y);
|
||||
}
|
||||
|
||||
Vec2::Vec2()
|
||||
: x(0.0f), y(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
Vec2::Vec2(float xx, float yy)
|
||||
: x(xx), y(yy)
|
||||
{
|
||||
}
|
||||
|
||||
Vec2::Vec2(const float* array)
|
||||
{
|
||||
set(array);
|
||||
}
|
||||
|
||||
Vec2::Vec2(const Vec2& p1, const Vec2& p2)
|
||||
{
|
||||
set(p1, p2);
|
||||
}
|
||||
|
||||
Vec2::Vec2(const Vec2& copy)
|
||||
{
|
||||
set(copy);
|
||||
}
|
||||
|
||||
Vec2::~Vec2()
|
||||
{
|
||||
}
|
||||
|
||||
bool Vec2::isZero() const
|
||||
{
|
||||
return x == 0.0f && y == 0.0f;
|
||||
}
|
||||
|
||||
bool Vec2::isOne() const
|
||||
{
|
||||
return x == 1.0f && y == 1.0f;
|
||||
}
|
||||
|
||||
float Vec2::angle(const Vec2& v1, const Vec2& v2)
|
||||
{
|
||||
float dz = v1.x * v2.y - v1.y * v2.x;
|
||||
return atan2f(fabsf(dz) + MATH_FLOAT_SMALL, dot(v1, v2));
|
||||
}
|
||||
|
||||
void Vec2::add(const Vec2& v)
|
||||
{
|
||||
x += v.x;
|
||||
y += v.y;
|
||||
}
|
||||
|
||||
void Vec2::add(const Vec2& v1, const Vec2& v2, Vec2* dst)
|
||||
{
|
||||
GP_ASSERT(dst);
|
||||
|
@ -171,18 +126,6 @@ float Vec2::distance(const Vec2& v) const
|
|||
return sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
float Vec2::distanceSquared(const Vec2& v) const
|
||||
{
|
||||
float dx = v.x - x;
|
||||
float dy = v.y - y;
|
||||
return (dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
float Vec2::dot(const Vec2& v) const
|
||||
{
|
||||
return (x * v.x + y * v.y);
|
||||
}
|
||||
|
||||
float Vec2::dot(const Vec2& v1, const Vec2& v2)
|
||||
{
|
||||
return (v1.x * v2.x + v1.y * v2.y);
|
||||
|
@ -193,17 +136,6 @@ float Vec2::length() const
|
|||
return sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
float Vec2::lengthSquared() const
|
||||
{
|
||||
return (x * x + y * y);
|
||||
}
|
||||
|
||||
void Vec2::negate()
|
||||
{
|
||||
x = -x;
|
||||
y = -y;
|
||||
}
|
||||
|
||||
void Vec2::normalize()
|
||||
{
|
||||
float n = x * x + y * y;
|
||||
|
@ -228,18 +160,6 @@ Vec2 Vec2::getNormalized() const
|
|||
return v;
|
||||
}
|
||||
|
||||
void Vec2::scale(float scalar)
|
||||
{
|
||||
x *= scalar;
|
||||
y *= scalar;
|
||||
}
|
||||
|
||||
void Vec2::scale(const Vec2& scale)
|
||||
{
|
||||
x *= scale.x;
|
||||
y *= scale.y;
|
||||
}
|
||||
|
||||
void Vec2::rotate(const Vec2& point, float angle)
|
||||
{
|
||||
double sinAngle = sin(angle);
|
||||
|
@ -261,12 +181,6 @@ void Vec2::rotate(const Vec2& point, float angle)
|
|||
}
|
||||
}
|
||||
|
||||
void Vec2::set(float xx, float yy)
|
||||
{
|
||||
this->x = xx;
|
||||
this->y = yy;
|
||||
}
|
||||
|
||||
void Vec2::set(const float* array)
|
||||
{
|
||||
GP_ASSERT(array);
|
||||
|
@ -275,24 +189,6 @@ void Vec2::set(const float* array)
|
|||
y = array[1];
|
||||
}
|
||||
|
||||
void Vec2::set(const Vec2& v)
|
||||
{
|
||||
this->x = v.x;
|
||||
this->y = v.y;
|
||||
}
|
||||
|
||||
void Vec2::set(const Vec2& p1, const Vec2& p2)
|
||||
{
|
||||
x = p2.x - p1.x;
|
||||
y = p2.y - p1.y;
|
||||
}
|
||||
|
||||
void Vec2::subtract(const Vec2& v)
|
||||
{
|
||||
x -= v.x;
|
||||
y -= v.y;
|
||||
}
|
||||
|
||||
void Vec2::subtract(const Vec2& v1, const Vec2& v2, Vec2* dst)
|
||||
{
|
||||
GP_ASSERT(dst);
|
||||
|
@ -301,20 +197,6 @@ void Vec2::subtract(const Vec2& v1, const Vec2& v2, Vec2* dst)
|
|||
dst->y = v1.y - v2.y;
|
||||
}
|
||||
|
||||
void Vec2::smooth(const Vec2& target, float elapsedTime, float responseTime)
|
||||
{
|
||||
if (elapsedTime > 0)
|
||||
{
|
||||
*this += (target - *this) * (elapsedTime / (elapsedTime + responseTime));
|
||||
}
|
||||
}
|
||||
|
||||
void Vec2::setPoint(float xx, float yy)
|
||||
{
|
||||
this->x = xx;
|
||||
this->y = yy;
|
||||
}
|
||||
|
||||
bool Vec2::equals(const Vec2& target) const
|
||||
{
|
||||
return (fabs(this->x - target.x) < FLT_EPSILON)
|
||||
|
@ -449,18 +331,18 @@ Vec2 Vec2::getIntersectPoint(const Vec2& A, const Vec2& B, const Vec2& C, const
|
|||
return Vec2::ZERO;
|
||||
}
|
||||
|
||||
const Vec2 Vec2::ZERO = Vec2(0.0f, 0.0f);
|
||||
const Vec2 Vec2::ONE = Vec2(1.0f, 1.0f);
|
||||
const Vec2 Vec2::UNIT_X = Vec2(1.0f, 0.0f);
|
||||
const Vec2 Vec2::UNIT_Y = Vec2(0.0f, 1.0f);
|
||||
const Vec2 Vec2::ANCHOR_MIDDLE = Vec2(0.5f, 0.5f);
|
||||
const Vec2 Vec2::ANCHOR_BOTTOM_LEFT = Vec2(0.0f, 0.0f);
|
||||
const Vec2 Vec2::ANCHOR_TOP_LEFT = Vec2(0.0f, 1.0f);
|
||||
const Vec2 Vec2::ANCHOR_BOTTOM_RIGHT = Vec2(1.0f, 0.0f);
|
||||
const Vec2 Vec2::ANCHOR_TOP_RIGHT = Vec2(1.0f, 1.0f);
|
||||
const Vec2 Vec2::ANCHOR_MIDDLE_RIGHT = Vec2(1.0f, 0.5f);
|
||||
const Vec2 Vec2::ANCHOR_MIDDLE_LEFT = Vec2(0.0f, 0.5f);
|
||||
const Vec2 Vec2::ANCHOR_MIDDLE_TOP = Vec2(0.5f, 1.0f);
|
||||
const Vec2 Vec2::ANCHOR_MIDDLE_BOTTOM = Vec2(0.5f, 0.0f);
|
||||
const Vec2 Vec2::ZERO(0.0f, 0.0f);
|
||||
const Vec2 Vec2::ONE(1.0f, 1.0f);
|
||||
const Vec2 Vec2::UNIT_X(1.0f, 0.0f);
|
||||
const Vec2 Vec2::UNIT_Y(0.0f, 1.0f);
|
||||
const Vec2 Vec2::ANCHOR_MIDDLE(0.5f, 0.5f);
|
||||
const Vec2 Vec2::ANCHOR_BOTTOM_LEFT(0.0f, 0.0f);
|
||||
const Vec2 Vec2::ANCHOR_TOP_LEFT(0.0f, 1.0f);
|
||||
const Vec2 Vec2::ANCHOR_BOTTOM_RIGHT(1.0f, 0.0f);
|
||||
const Vec2 Vec2::ANCHOR_TOP_RIGHT(1.0f, 1.0f);
|
||||
const Vec2 Vec2::ANCHOR_MIDDLE_RIGHT(1.0f, 0.5f);
|
||||
const Vec2 Vec2::ANCHOR_MIDDLE_LEFT(0.0f, 0.5f);
|
||||
const Vec2 Vec2::ANCHOR_MIDDLE_TOP(0.5f, 1.0f);
|
||||
const Vec2 Vec2::ANCHOR_MIDDLE_BOTTOM(0.5f, 0.0f);
|
||||
|
||||
NS_CC_MATH_END
|
||||
|
|
|
@ -109,14 +109,14 @@ public:
|
|||
*
|
||||
* @return true if this vector contains all zeros, false otherwise.
|
||||
*/
|
||||
bool isZero() const;
|
||||
inline bool isZero() const;
|
||||
|
||||
/**
|
||||
* Indicates whether this vector contains all ones.
|
||||
*
|
||||
* @return true if this vector contains all ones, false otherwise.
|
||||
*/
|
||||
bool isOne() const;
|
||||
inline bool isOne() const;
|
||||
|
||||
/**
|
||||
* Returns the angle (in radians) between the specified vectors.
|
||||
|
@ -133,7 +133,7 @@ public:
|
|||
*
|
||||
* @param v The vector to add.
|
||||
*/
|
||||
void add(const Vec2& v);
|
||||
inline void add(const Vec2& v);
|
||||
|
||||
/**
|
||||
* Adds the specified vectors and stores the result in dst.
|
||||
|
@ -187,7 +187,7 @@ public:
|
|||
*
|
||||
* @see distance
|
||||
*/
|
||||
float distanceSquared(const Vec2& v) const;
|
||||
inline float distanceSquared(const Vec2& v) const;
|
||||
|
||||
/**
|
||||
* Returns the dot product of this vector and the specified vector.
|
||||
|
@ -196,7 +196,7 @@ public:
|
|||
*
|
||||
* @return The dot product.
|
||||
*/
|
||||
float dot(const Vec2& v) const;
|
||||
inline float dot(const Vec2& v) const;
|
||||
|
||||
/**
|
||||
* Returns the dot product between the specified vectors.
|
||||
|
@ -229,12 +229,12 @@ public:
|
|||
*
|
||||
* @see length
|
||||
*/
|
||||
float lengthSquared() const;
|
||||
inline float lengthSquared() const;
|
||||
|
||||
/**
|
||||
* Negates this vector.
|
||||
*/
|
||||
void negate();
|
||||
inline void negate();
|
||||
|
||||
/**
|
||||
* Normalizes this vector.
|
||||
|
@ -259,14 +259,14 @@ public:
|
|||
*
|
||||
* @param scalar The scalar value.
|
||||
*/
|
||||
void scale(float scalar);
|
||||
inline void scale(float scalar);
|
||||
|
||||
/**
|
||||
* Scales each element of this vector by the matching component of scale.
|
||||
*
|
||||
* @param scale The vector to scale by.
|
||||
*/
|
||||
void scale(const Vec2& scale);
|
||||
inline void scale(const Vec2& scale);
|
||||
|
||||
/**
|
||||
* Rotates this vector by angle (specified in radians) around the given point.
|
||||
|
@ -282,7 +282,7 @@ public:
|
|||
* @param xx The new x coordinate.
|
||||
* @param yy The new y coordinate.
|
||||
*/
|
||||
void set(float xx, float yy);
|
||||
inline void set(float xx, float yy);
|
||||
|
||||
/**
|
||||
* Sets the elements of this vector from the values in the specified array.
|
||||
|
@ -296,7 +296,7 @@ public:
|
|||
*
|
||||
* @param v The vector to copy.
|
||||
*/
|
||||
void set(const Vec2& v);
|
||||
inline void set(const Vec2& v);
|
||||
|
||||
/**
|
||||
* Sets this vector to the directional vector between the specified points.
|
||||
|
@ -304,7 +304,12 @@ public:
|
|||
* @param p1 The first point.
|
||||
* @param p2 The second point.
|
||||
*/
|
||||
void set(const Vec2& p1, const Vec2& p2);
|
||||
inline void set(const Vec2& p1, const Vec2& p2);
|
||||
|
||||
/**
|
||||
* Sets the elements of this vector to zero.
|
||||
*/
|
||||
inline void setZero();
|
||||
|
||||
/**
|
||||
* Subtracts this vector and the specified vector as (this - v)
|
||||
|
@ -312,7 +317,7 @@ public:
|
|||
*
|
||||
* @param v The vector to subtract.
|
||||
*/
|
||||
void subtract(const Vec2& v);
|
||||
inline void subtract(const Vec2& v);
|
||||
|
||||
/**
|
||||
* Subtracts the specified vectors and stores the result in dst.
|
||||
|
@ -335,7 +340,7 @@ public:
|
|||
* @param elapsedTime elapsed time between calls.
|
||||
* @param responseTime response time (in the same units as elapsedTime).
|
||||
*/
|
||||
void smooth(const Vec2& target, float elapsedTime, float responseTime);
|
||||
inline void smooth(const Vec2& target, float elapsedTime, float responseTime);
|
||||
|
||||
/**
|
||||
* Calculates the sum of this vector with the given vector.
|
||||
|
@ -452,7 +457,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setPoint(float xx, float yy);
|
||||
inline void setPoint(float xx, float yy);
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,123 @@
|
|||
|
||||
NS_CC_MATH_BEGIN
|
||||
|
||||
inline Vec2::Vec2()
|
||||
: x(0.0f), y(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
inline Vec2::Vec2(float xx, float yy)
|
||||
: x(xx), y(yy)
|
||||
{
|
||||
}
|
||||
|
||||
inline Vec2::Vec2(const float* array)
|
||||
{
|
||||
set(array);
|
||||
}
|
||||
|
||||
inline Vec2::Vec2(const Vec2& p1, const Vec2& p2)
|
||||
{
|
||||
set(p1, p2);
|
||||
}
|
||||
|
||||
inline Vec2::Vec2(const Vec2& copy)
|
||||
{
|
||||
set(copy);
|
||||
}
|
||||
|
||||
inline Vec2::~Vec2()
|
||||
{
|
||||
}
|
||||
|
||||
inline bool Vec2::isZero() const
|
||||
{
|
||||
return x == 0.0f && y == 0.0f;
|
||||
}
|
||||
|
||||
bool Vec2::isOne() const
|
||||
{
|
||||
return x == 1.0f && y == 1.0f;
|
||||
}
|
||||
|
||||
inline void Vec2::add(const Vec2& v)
|
||||
{
|
||||
x += v.x;
|
||||
y += v.y;
|
||||
}
|
||||
|
||||
inline float Vec2::distanceSquared(const Vec2& v) const
|
||||
{
|
||||
float dx = v.x - x;
|
||||
float dy = v.y - y;
|
||||
return (dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
inline float Vec2::dot(const Vec2& v) const
|
||||
{
|
||||
return (x * v.x + y * v.y);
|
||||
}
|
||||
|
||||
inline float Vec2::lengthSquared() const
|
||||
{
|
||||
return (x * x + y * y);
|
||||
}
|
||||
|
||||
inline void Vec2::negate()
|
||||
{
|
||||
x = -x;
|
||||
y = -y;
|
||||
}
|
||||
|
||||
inline void Vec2::scale(float scalar)
|
||||
{
|
||||
x *= scalar;
|
||||
y *= scalar;
|
||||
}
|
||||
|
||||
inline void Vec2::scale(const Vec2& scale)
|
||||
{
|
||||
x *= scale.x;
|
||||
y *= scale.y;
|
||||
}
|
||||
|
||||
inline void Vec2::set(float xx, float yy)
|
||||
{
|
||||
this->x = xx;
|
||||
this->y = yy;
|
||||
}
|
||||
|
||||
inline void Vec2::set(const Vec2& v)
|
||||
{
|
||||
this->x = v.x;
|
||||
this->y = v.y;
|
||||
}
|
||||
|
||||
inline void Vec2::set(const Vec2& p1, const Vec2& p2)
|
||||
{
|
||||
x = p2.x - p1.x;
|
||||
y = p2.y - p1.y;
|
||||
}
|
||||
|
||||
void Vec2::setZero()
|
||||
{
|
||||
x = y = 0.0f;
|
||||
}
|
||||
|
||||
inline void Vec2::subtract(const Vec2& v)
|
||||
{
|
||||
x -= v.x;
|
||||
y -= v.y;
|
||||
}
|
||||
|
||||
inline void Vec2::smooth(const Vec2& target, float elapsedTime, float responseTime)
|
||||
{
|
||||
if (elapsedTime > 0)
|
||||
{
|
||||
*this += (target - *this) * (elapsedTime / (elapsedTime + responseTime));
|
||||
}
|
||||
}
|
||||
|
||||
inline const Vec2 Vec2::operator+(const Vec2& v) const
|
||||
{
|
||||
Vec2 result(*this);
|
||||
|
@ -108,4 +225,10 @@ inline const Vec2 operator*(float x, const Vec2& v)
|
|||
return result;
|
||||
}
|
||||
|
||||
void Vec2::setPoint(float xx, float yy)
|
||||
{
|
||||
this->x = xx;
|
||||
this->y = yy;
|
||||
}
|
||||
|
||||
NS_CC_MATH_END
|
||||
|
|
|
@ -69,7 +69,6 @@ PhysicsBody::PhysicsBody()
|
|||
, _angularDamping(0.0f)
|
||||
, _tag(0)
|
||||
, _positionInitDirty(true)
|
||||
, _recordedPosition(Vec2::ZERO)
|
||||
, _rotationOffset(0)
|
||||
, _recordedRotation(0.0f)
|
||||
, _recordedAngle(0.0)
|
||||
|
|
|
@ -880,11 +880,44 @@ bool Image::decodeWithWIC(const unsigned char *data, ssize_t dataLen)
|
|||
|
||||
bool Image::encodeWithWIC(const std::string& filePath, bool isToRGB, GUID containerFormat)
|
||||
{
|
||||
WICPixelFormatGUID format = isToRGB ? GUID_WICPixelFormat24bppRGB : GUID_WICPixelFormat32bppRGBA;
|
||||
// Save formats supported by WIC
|
||||
WICPixelFormatGUID targetFormat = isToRGB ? GUID_WICPixelFormat24bppBGR : GUID_WICPixelFormat32bppBGRA;
|
||||
unsigned char *pSaveData = nullptr;
|
||||
int saveLen = _dataLen;
|
||||
int bpp = 4;
|
||||
|
||||
WICImageLoader img;
|
||||
return img.encodeImageData(filePath, _data, _dataLen, format, _width, _height, containerFormat);
|
||||
if (targetFormat == GUID_WICPixelFormat24bppBGR && _renderFormat == Texture2D::PixelFormat::RGBA8888)
|
||||
{
|
||||
bpp = 3;
|
||||
saveLen = _width * _height * bpp;
|
||||
pSaveData = new unsigned char[saveLen];
|
||||
int indL = 0, indR = 0;
|
||||
|
||||
while (indL < saveLen && indR < _dataLen)
|
||||
{
|
||||
memcpy(&pSaveData[indL], &_data[indR], 3);
|
||||
indL += 3;
|
||||
indR += 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pSaveData = new unsigned char[saveLen];
|
||||
memcpy(pSaveData, _data, saveLen);
|
||||
}
|
||||
|
||||
for (int ind = 2; ind < saveLen; ind += bpp) {
|
||||
std::swap(pSaveData[ind - 2], pSaveData[ind]);
|
||||
}
|
||||
|
||||
bool bRet = false;
|
||||
WICImageLoader img;
|
||||
bRet = img.encodeImageData(filePath, pSaveData, saveLen, targetFormat, _width, _height, containerFormat);
|
||||
|
||||
delete[] pSaveData;
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
||||
#endif //CC_USE_WIC
|
||||
|
||||
|
|
|
@ -36,6 +36,10 @@ using namespace Windows::UI::Xaml::Input;
|
|||
using namespace Windows::UI::Xaml::Media;
|
||||
using namespace Windows::UI::Xaml::Navigation;
|
||||
|
||||
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
||||
using namespace Windows::Phone::UI::Input;
|
||||
#endif
|
||||
|
||||
OpenGLESPage::OpenGLESPage() :
|
||||
OpenGLESPage(nullptr)
|
||||
{
|
||||
|
@ -76,6 +80,7 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) :
|
|||
|
||||
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
||||
Windows::UI::ViewManagement::StatusBar::GetForCurrentView()->HideAsync();
|
||||
HardwareButtons::BackPressed += ref new EventHandler<BackPressedEventArgs^>(this, &OpenGLESPage::OnBackButtonPressed);
|
||||
#else
|
||||
// Disable all pointer visual feedback for better performance when touching.
|
||||
// This is not supported on Windows Phone applications.
|
||||
|
@ -163,6 +168,21 @@ void OpenGLESPage::OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Wi
|
|||
}
|
||||
}
|
||||
|
||||
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
||||
void OpenGLESPage::OnBackButtonPressed(Object^ sender, BackPressedEventArgs^ args)
|
||||
{
|
||||
bool myAppCanNavigate = false;
|
||||
if (myAppCanNavigate)
|
||||
{
|
||||
args->Handled = true;
|
||||
}
|
||||
else {
|
||||
// Do nothing. Leave args->Handled set to the current value, false.
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void OpenGLESPage::OnSwapChainPanelSizeChanged(Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e)
|
||||
{
|
||||
// Size change events occur outside of the render thread. A lock is required when updating
|
||||
|
@ -283,6 +303,11 @@ void OpenGLESPage::StartRenderLoop()
|
|||
{
|
||||
m_deviceLost = true;
|
||||
|
||||
if (m_renderer)
|
||||
{
|
||||
m_renderer->Pause();
|
||||
}
|
||||
|
||||
// XAML objects like the SwapChainPanel must only be manipulated on the UI thread.
|
||||
swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([=]()
|
||||
{
|
||||
|
@ -292,6 +317,11 @@ void OpenGLESPage::StartRenderLoop()
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_renderer)
|
||||
{
|
||||
m_renderer->Pause();
|
||||
}
|
||||
});
|
||||
|
||||
// Run task on a dedicated high priority background thread.
|
||||
|
@ -305,9 +335,4 @@ void OpenGLESPage::StopRenderLoop()
|
|||
mRenderLoopWorker->Cancel();
|
||||
mRenderLoopWorker = nullptr;
|
||||
}
|
||||
|
||||
if (m_renderer)
|
||||
{
|
||||
m_renderer->Pause();
|
||||
}
|
||||
}
|
|
@ -39,6 +39,9 @@ namespace cocos2d
|
|||
void OnPageLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
|
||||
void OnSwapChainPanelSizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e);
|
||||
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
||||
void OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args);
|
||||
#endif
|
||||
void GetSwapChainPanelSize(GLsizei* width, GLsizei* height);
|
||||
void CreateRenderSurface();
|
||||
void DestroyRenderSurface();
|
||||
|
|
|
@ -325,23 +325,21 @@ WICPixelFormatGUID WICImageLoader::getPixelFormat()
|
|||
return _format;
|
||||
}
|
||||
|
||||
bool WICImageLoader::encodeImageData(std::string path, ImageBlob data, size_t dataLen, WICPixelFormatGUID pixelFormat, int width, int height, GUID containerFormat)
|
||||
bool WICImageLoader::encodeImageData(std::string path, const unsigned char* data, size_t dataLen, WICPixelFormatGUID pixelFormat, int width, int height, GUID containerFormat)
|
||||
{
|
||||
assert(data != NULL);
|
||||
assert(dataLen > 0 && width > 0 && height > 0);
|
||||
|
||||
IWICImagingFactory* pFact = getWICFactory();
|
||||
|
||||
HRESULT hr = S_FALSE;
|
||||
HRESULT hr = E_FAIL;
|
||||
IWICStream* pStream = NULL;
|
||||
|
||||
if(NULL != pFact)
|
||||
{
|
||||
if (NULL != pFact) {
|
||||
hr = pFact->CreateStream(&pStream);
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
if (SUCCEEDED(hr)) {
|
||||
std::wstring wpath;
|
||||
wpath.assign(path.begin(), path.end());
|
||||
hr = pStream->InitializeFromFilename(wpath.c_str(), GENERIC_WRITE);
|
||||
|
@ -349,54 +347,50 @@ bool WICImageLoader::encodeImageData(std::string path, ImageBlob data, size_t da
|
|||
|
||||
IWICBitmapEncoder* pEnc = NULL;
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = pFact->CreateEncoder(containerFormat, NULL, &pEnc);
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = pEnc->Initialize(pStream, WICBitmapEncoderNoCache);
|
||||
}
|
||||
|
||||
IWICBitmapFrameEncode* pFrame = NULL;
|
||||
IPropertyBag2* pProp = NULL;
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = pEnc->CreateNewFrame(&pFrame, &pProp);
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = pFrame->Initialize(pProp);
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = pFrame->SetSize(width, height);
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
hr = pFrame->SetPixelFormat(&pixelFormat);
|
||||
if (SUCCEEDED(hr)) {
|
||||
WICPixelFormatGUID targetFormat = pixelFormat;
|
||||
hr = pFrame->SetPixelFormat(&targetFormat);
|
||||
|
||||
if (targetFormat != pixelFormat) {
|
||||
hr = E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
if (SUCCEEDED(hr)) {
|
||||
size_t bpp = getBitsPerPixel(pixelFormat);
|
||||
size_t stride = (width * bpp + 7) / 8;
|
||||
|
||||
hr = pFrame->WritePixels(height, stride, dataLen, (BYTE*)data);
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = pFrame->Commit();
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = pEnc->Commit();
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
WICPixelFormatGUID getPixelFormat();
|
||||
int getImageData(ImageBlob rawData, size_t dataLen);
|
||||
bool decodeImageData(ImageBlob data, size_t dataLen);
|
||||
bool encodeImageData(std::string path, ImageBlob data, size_t dataLen, WICPixelFormatGUID pixelFormat, int width, int height, GUID containerFormat);
|
||||
bool encodeImageData(std::string path, const unsigned char* data, size_t dataLen, WICPixelFormatGUID pixelFormat, int width, int height, GUID containerFormat);
|
||||
|
||||
protected:
|
||||
bool processImage(IWICBitmapDecoder* decoder);
|
||||
|
|
|
@ -502,11 +502,11 @@ void Layout::setStencilClippingSize(const Size &size)
|
|||
if (_clippingEnabled && _clippingType == ClippingType::STENCIL)
|
||||
{
|
||||
Vec2 rect[4];
|
||||
rect[0] = Vec2::ZERO;
|
||||
rect[1] = Vec2(_contentSize.width, 0);
|
||||
rect[2] = Vec2(_contentSize.width, _contentSize.height);
|
||||
rect[3] = Vec2(0, _contentSize.height);
|
||||
Color4F green(0, 1, 0, 1);
|
||||
// rect[0].setZero(); Zero default
|
||||
rect[1].set(_contentSize.width, 0.0f);
|
||||
rect[2].set(_contentSize.width, _contentSize.height);
|
||||
rect[3].set(0.0f, _contentSize.height);
|
||||
Color4F green(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
_clippingStencil->clear();
|
||||
_clippingStencil->drawPolygon(rect, 4, green, 0, green);
|
||||
}
|
||||
|
|
|
@ -30,17 +30,16 @@ namespace ui {
|
|||
|
||||
static const float AUTOSCROLLMAXSPEED = 1000.0f;
|
||||
|
||||
const Vec2 SCROLLDIR_UP = Vec2(0.0f, 1.0f);
|
||||
const Vec2 SCROLLDIR_DOWN = Vec2(0.0f, -1.0f);
|
||||
const Vec2 SCROLLDIR_LEFT = Vec2(-1.0f, 0.0f);
|
||||
const Vec2 SCROLLDIR_RIGHT = Vec2(1.0f, 0.0f);
|
||||
const Vec2 SCROLLDIR_UP(0.0f, 1.0f);
|
||||
const Vec2 SCROLLDIR_DOWN(0.0f, -1.0f);
|
||||
const Vec2 SCROLLDIR_LEFT(-1.0f, 0.0f);
|
||||
const Vec2 SCROLLDIR_RIGHT(1.0f, 0.0f);
|
||||
|
||||
IMPLEMENT_CLASS_GUI_INFO(ScrollView)
|
||||
|
||||
ScrollView::ScrollView():
|
||||
_innerContainer(nullptr),
|
||||
_direction(Direction::VERTICAL),
|
||||
_autoScrollDir(Vec2::ZERO),
|
||||
_topBoundary(0.0f),
|
||||
_bottomBoundary(0.0f),
|
||||
_leftBoundary(0.0f),
|
||||
|
@ -55,10 +54,8 @@ _autoScrollOriginalSpeed(0.0f),
|
|||
_autoScrollAcceleration(-1000.0f),
|
||||
_isAutoScrollSpeedAttenuated(false),
|
||||
_needCheckAutoScrollDestination(false),
|
||||
_autoScrollDestination(Vec2::ZERO),
|
||||
_bePressed(false),
|
||||
_slidTime(0.0f),
|
||||
_moveChildPoint(Vec2::ZERO),
|
||||
_childFocusCancelOffset(5.0f),
|
||||
_leftBounceNeeded(false),
|
||||
_topBounceNeeded(false),
|
||||
|
@ -66,7 +63,6 @@ _rightBounceNeeded(false),
|
|||
_bottomBounceNeeded(false),
|
||||
_bounceEnabled(false),
|
||||
_bouncing(false),
|
||||
_bounceDir(Vec2::ZERO),
|
||||
_bounceOriginalSpeed(0.0f),
|
||||
_inertiaScrollEnabled(true),
|
||||
_scrollViewEventListener(nullptr),
|
||||
|
|
|
@ -154,13 +154,8 @@ _sizeType(SizeType::ABSOLUTE),
|
|||
_positionType(PositionType::ABSOLUTE),
|
||||
_actionTag(0),
|
||||
_customSize(Size::ZERO),
|
||||
_sizePercent(Vec2::ZERO),
|
||||
_positionPercent(Vec2::ZERO),
|
||||
_hitted(false),
|
||||
_touchListener(nullptr),
|
||||
_touchBeganPosition(Vec2::ZERO),
|
||||
_touchMovePosition(Vec2::ZERO),
|
||||
_touchEndPosition(Vec2::ZERO),
|
||||
_flippedX(false),
|
||||
_flippedY(false),
|
||||
_layoutParameterType(LayoutParameter::Type::NONE),
|
||||
|
@ -309,7 +304,7 @@ void Widget::setContentSize(const cocos2d::Size &contentSize)
|
|||
{
|
||||
spy = _customSize.height / pSize.height;
|
||||
}
|
||||
_sizePercent = Vec2(spx, spy);
|
||||
_sizePercent.set(spx, spy);
|
||||
}
|
||||
onSizeChanged();
|
||||
}
|
||||
|
@ -387,7 +382,7 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize)
|
|||
{
|
||||
spy = _customSize.height / parentSize.height;
|
||||
}
|
||||
_sizePercent = Vec2(spx, spy);
|
||||
_sizePercent.set(spx, spy);
|
||||
break;
|
||||
}
|
||||
case SizeType::PERCENT:
|
||||
|
@ -416,17 +411,17 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize)
|
|||
{
|
||||
if (parentSize.width <= 0.0f || parentSize.height <= 0.0f)
|
||||
{
|
||||
_positionPercent = Vec2::ZERO;
|
||||
_positionPercent.setZero();
|
||||
}
|
||||
else
|
||||
{
|
||||
_positionPercent = Vec2(absPos.x / parentSize.width, absPos.y / parentSize.height);
|
||||
_positionPercent.set(absPos.x / parentSize.width, absPos.y / parentSize.height);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PositionType::PERCENT:
|
||||
{
|
||||
absPos = Vec2(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
||||
absPos.set(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -994,11 +989,11 @@ void Widget::setPosition(const Vec2 &pos)
|
|||
Size pSize = widgetParent->getContentSize();
|
||||
if (pSize.width <= 0.0f || pSize.height <= 0.0f)
|
||||
{
|
||||
_positionPercent = Vec2::ZERO;
|
||||
_positionPercent.setZero();
|
||||
}
|
||||
else
|
||||
{
|
||||
_positionPercent = Vec2(pos.x / pSize.width, pos.y / pSize.height);
|
||||
_positionPercent.set(pos.x / pSize.width, pos.y / pSize.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1023,7 +1018,7 @@ void Widget::setPositionPercent(const Vec2 &percent)
|
|||
if (widgetParent)
|
||||
{
|
||||
Size parentSize = widgetParent->getContentSize();
|
||||
Vec2 absPos = Vec2(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
||||
Vec2 absPos(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y);
|
||||
setPosition(absPos);
|
||||
}
|
||||
}
|
||||
|
@ -1038,7 +1033,7 @@ const Vec2& Widget::getPositionPercent(){
|
|||
float percentX = component->getPositionPercentX();
|
||||
float percentY = component->getPositionPercentY();
|
||||
|
||||
_positionPercent = Vec2(percentX, percentY);
|
||||
_positionPercent.set(percentX, percentY);
|
||||
}
|
||||
return _positionPercent;
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ void ControlSaturationBrightnessPicker::updateWithHSV(HSV hsv)
|
|||
void ControlSaturationBrightnessPicker::updateDraggerWithHSV(HSV hsv)
|
||||
{
|
||||
// Set the position of the slider to the correct saturation and brightness
|
||||
Vec2 pos = Vec2(_startPos.x + boxPos + (boxSize*(1 - hsv.s)),
|
||||
Vec2 pos(_startPos.x + boxPos + (boxSize*(1 - hsv.s)),
|
||||
_startPos.y + boxPos + (boxSize*hsv.v));
|
||||
|
||||
// update
|
||||
|
|
|
@ -254,7 +254,7 @@ void ScrollView::setZoomScale(float s)
|
|||
|
||||
if (_touchLength == 0.0f)
|
||||
{
|
||||
center = Vec2(_viewSize.width*0.5f, _viewSize.height*0.5f);
|
||||
center.set(_viewSize.width*0.5f, _viewSize.height*0.5f);
|
||||
center = this->convertToWorldSpace(center);
|
||||
}
|
||||
else
|
||||
|
@ -481,10 +481,10 @@ void ScrollView::updateInset()
|
|||
if (this->getContainer() != nullptr)
|
||||
{
|
||||
_maxInset = this->maxContainerOffset();
|
||||
_maxInset = Vec2(_maxInset.x + _viewSize.width * INSET_RATIO,
|
||||
_maxInset.set(_maxInset.x + _viewSize.width * INSET_RATIO,
|
||||
_maxInset.y + _viewSize.height * INSET_RATIO);
|
||||
_minInset = this->minContainerOffset();
|
||||
_minInset = Vec2(_minInset.x - _viewSize.width * INSET_RATIO,
|
||||
_minInset.set(_minInset.x - _viewSize.width * INSET_RATIO,
|
||||
_minInset.y - _viewSize.height * INSET_RATIO);
|
||||
}
|
||||
}
|
||||
|
@ -664,7 +664,7 @@ bool ScrollView::onTouchBegan(Touch* touch, Event* event)
|
|||
_touchPoint = this->convertTouchToNodeSpace(touch);
|
||||
_touchMoved = false;
|
||||
_dragging = true; //dragging started
|
||||
_scrollDistance = Vec2(0.0f, 0.0f);
|
||||
_scrollDistance.setZero();
|
||||
_touchLength = 0.0f;
|
||||
}
|
||||
else if (_touches.size() == 2)
|
||||
|
@ -740,7 +740,7 @@ void ScrollView::onTouchMoved(Touch* touch, Event* event)
|
|||
|
||||
if (!_touchMoved)
|
||||
{
|
||||
moveDistance = Vec2::ZERO;
|
||||
moveDistance.setZero();
|
||||
}
|
||||
|
||||
_touchPoint = newPoint;
|
||||
|
@ -751,10 +751,10 @@ void ScrollView::onTouchMoved(Touch* touch, Event* event)
|
|||
switch (_direction)
|
||||
{
|
||||
case Direction::VERTICAL:
|
||||
moveDistance = Vec2(0.0f, moveDistance.y);
|
||||
moveDistance.set(0.0f, moveDistance.y);
|
||||
break;
|
||||
case Direction::HORIZONTAL:
|
||||
moveDistance = Vec2(moveDistance.x, 0.0f);
|
||||
moveDistance.set(moveDistance.x, 0.0f);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -320,10 +320,10 @@ Vec2 TableView::__offsetFromIndex(ssize_t index)
|
|||
switch (this->getDirection())
|
||||
{
|
||||
case Direction::HORIZONTAL:
|
||||
offset = Vec2(_vCellsPositions[index], 0.0f);
|
||||
offset.set(_vCellsPositions[index], 0.0f);
|
||||
break;
|
||||
default:
|
||||
offset = Vec2(0.0f, _vCellsPositions[index]);
|
||||
offset.set(0.0f, _vCellsPositions[index]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,19 +124,19 @@ void Particle3DQuadRender::render(Renderer* renderer, const Mat4 &transform, Par
|
|||
position = particle->position;
|
||||
_posuvcolors[vertexindex].position = (position + (- halfwidth - halfheight));
|
||||
_posuvcolors[vertexindex].color = particle->color;
|
||||
_posuvcolors[vertexindex].uv = Vec2(particle->lb_uv);
|
||||
_posuvcolors[vertexindex].uv.set(particle->lb_uv);
|
||||
|
||||
_posuvcolors[vertexindex + 1].position = (position + (halfwidth - halfheight));
|
||||
_posuvcolors[vertexindex + 1].color = particle->color;
|
||||
_posuvcolors[vertexindex + 1].uv = Vec2(particle->rt_uv.x, particle->lb_uv.y);
|
||||
_posuvcolors[vertexindex + 1].uv.set(particle->rt_uv.x, particle->lb_uv.y);
|
||||
|
||||
_posuvcolors[vertexindex + 2].position = (position + (- halfwidth + halfheight));
|
||||
_posuvcolors[vertexindex + 2].color = particle->color;
|
||||
_posuvcolors[vertexindex + 2].uv = Vec2(particle->lb_uv.x, particle->rt_uv.y);
|
||||
_posuvcolors[vertexindex + 2].uv.set(particle->lb_uv.x, particle->rt_uv.y);
|
||||
|
||||
_posuvcolors[vertexindex + 3].position = (position + (halfwidth + halfheight));
|
||||
_posuvcolors[vertexindex + 3].color = particle->color;
|
||||
_posuvcolors[vertexindex + 3].uv = Vec2(particle->rt_uv);
|
||||
_posuvcolors[vertexindex + 3].uv.set(particle->rt_uv);
|
||||
|
||||
|
||||
_indexData[index] = vertexindex;
|
||||
|
|
|
@ -32,7 +32,6 @@ NS_CC_BEGIN
|
|||
Particle3D::Particle3D()
|
||||
: position(Vec3::ZERO)
|
||||
, color(Vec4::ONE)
|
||||
, lb_uv(Vec2::ZERO)
|
||||
, rt_uv(Vec2::ONE)
|
||||
, width(1.0f)
|
||||
, height(1.0f)
|
||||
|
|
|
@ -174,20 +174,20 @@ void PUParticle3DQuadRender::render(Renderer* renderer, const Mat4 &transform, P
|
|||
float sintheta = sinf(-particle->zRotation);
|
||||
Vec2 texOffset = particle->lb_uv + 0.5f * (particle->rt_uv - particle->lb_uv);
|
||||
Vec2 val;
|
||||
val = Vec2((particle->lb_uv.x - texOffset.x), (particle->lb_uv.y - texOffset.y));
|
||||
val = Vec2(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
val.set((particle->lb_uv.x - texOffset.x), (particle->lb_uv.y - texOffset.y));
|
||||
val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
fillVertex(vertexindex, (position + (- halfwidth - halfheight + halfwidth * offsetX + halfheight * offsetY)), particle->color, Vec2(val.x + texOffset.x, val.y + texOffset.y));
|
||||
|
||||
val = Vec2(particle->rt_uv.x - texOffset.x, particle->lb_uv.y - texOffset.y);
|
||||
val = Vec2(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
val.set(particle->rt_uv.x - texOffset.x, particle->lb_uv.y - texOffset.y);
|
||||
val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
fillVertex(vertexindex + 1, (position + (halfwidth - halfheight + halfwidth * offsetX + halfheight * offsetY)), particle->color, Vec2(val.x + texOffset.x, val.y + texOffset.y));
|
||||
|
||||
val = Vec2(particle->lb_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
|
||||
val = Vec2(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
val.set(particle->lb_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
|
||||
val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
fillVertex(vertexindex + 2, (position + (- halfwidth + halfheight + halfwidth * offsetX + halfheight * offsetY)), particle->color, Vec2(val.x + texOffset.x, val.y + texOffset.y));
|
||||
|
||||
val = Vec2(particle->rt_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
|
||||
val = Vec2(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
val.set(particle->rt_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
|
||||
val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
fillVertex(vertexindex + 3, (position + (halfwidth + halfheight + halfwidth * offsetX + halfheight * offsetY)), particle->color, Vec2(val.x + texOffset.x, val.y + texOffset.y));
|
||||
}else{
|
||||
Mat4::createRotation(backward, -particle->zRotation, &pRotMat);
|
||||
|
@ -202,25 +202,25 @@ void PUParticle3DQuadRender::render(Renderer* renderer, const Mat4 &transform, P
|
|||
|
||||
//_posuvcolors[vertexindex].position = (position + (- halfwidth - halfheight + halfwidth * offsetX + halfheight * offsetY));
|
||||
//_posuvcolors[vertexindex].color = particle->color;
|
||||
//_posuvcolors[vertexindex].uv = Vec2(val.x + texOffset.x, val.y + texOffset.y);
|
||||
//_posuvcolors[vertexindex].uv.set(val.x + texOffset.x, val.y + texOffset.y);
|
||||
|
||||
//val = Vec2(particle->rt_uv.x - texOffset.x, particle->lb_uv.y - texOffset.y);
|
||||
//val = Vec2(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
//val.set(particle->rt_uv.x - texOffset.x, particle->lb_uv.y - texOffset.y);
|
||||
//val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
//_posuvcolors[vertexindex + 1].position = (position + (halfwidth - halfheight + halfwidth * offsetX + halfheight * offsetY));
|
||||
//_posuvcolors[vertexindex + 1].color = particle->color;
|
||||
//_posuvcolors[vertexindex + 1].uv = Vec2(val.x + texOffset.x, val.y + texOffset.y);
|
||||
//_posuvcolors[vertexindex + 1].uv.set(val.x + texOffset.x, val.y + texOffset.y);
|
||||
//
|
||||
//val = Vec2(particle->lb_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
|
||||
//val = Vec2(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
//val.set(particle->lb_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
|
||||
//val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
//_posuvcolors[vertexindex + 2].position = (position + (- halfwidth + halfheight + halfwidth * offsetX + halfheight * offsetY));
|
||||
//_posuvcolors[vertexindex + 2].color = particle->color;
|
||||
//_posuvcolors[vertexindex + 2].uv = Vec2(val.x + texOffset.x, val.y + texOffset.y);
|
||||
//_posuvcolors[vertexindex + 2].uv.set(val.x + texOffset.x, val.y + texOffset.y);
|
||||
//
|
||||
//val = Vec2(particle->rt_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
|
||||
//val = Vec2(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
//val.set(particle->rt_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
|
||||
//val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
|
||||
//_posuvcolors[vertexindex + 3].position = (position + (halfwidth + halfheight + halfwidth * offsetX + halfheight * offsetY));
|
||||
//_posuvcolors[vertexindex + 3].color = particle->color;
|
||||
//_posuvcolors[vertexindex + 3].uv = Vec2(val.x + texOffset.x, val.y + texOffset.y);
|
||||
//_posuvcolors[vertexindex + 3].uv.set(val.x + texOffset.x, val.y + texOffset.y);
|
||||
//
|
||||
//
|
||||
//_indexData[index] = vertexindex;
|
||||
|
@ -372,7 +372,7 @@ void PUParticle3DQuadRender::determineUVCoords( PUParticle3D *particle )
|
|||
unsigned short currentCol = particle->textureCoordsCurrent - _textureCoordsColumns * currentRow;
|
||||
currentRow = _textureCoordsRows - currentRow - 1;
|
||||
|
||||
particle->lb_uv = Vec2(_textureCoordsColStep * currentCol, _textureCoordsRowStep * currentRow);
|
||||
particle->lb_uv.set(_textureCoordsColStep * currentCol, _textureCoordsRowStep * currentRow);
|
||||
particle->rt_uv = particle->lb_uv + Vec2(_textureCoordsColStep, _textureCoordsRowStep);
|
||||
}
|
||||
|
||||
|
|
|
@ -265,14 +265,14 @@ const Vec2& PhysicsSprite::getPosFromPhysics() const
|
|||
#if CC_ENABLE_CHIPMUNK_INTEGRATION
|
||||
|
||||
cpVect cpPos = cpBodyGetPos(_CPBody);
|
||||
s_physicPosion = Vec2(cpPos.x, cpPos.y);
|
||||
s_physicPosion.set(cpPos.x, cpPos.y);
|
||||
|
||||
#elif CC_ENABLE_BOX2D_INTEGRATION
|
||||
|
||||
b2Vec2 pos = _pB2Body->GetPosition();
|
||||
float x = pos.x * _PTMRatio;
|
||||
float y = pos.y * _PTMRatio;
|
||||
s_physicPosion = Vec2(x,y);
|
||||
s_physicPosion.set(x,y);
|
||||
#endif
|
||||
return s_physicPosion;
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ void PhysicsSprite::syncPhysicsTransform() const
|
|||
float c = cosf(radians);
|
||||
float s = sinf(radians);
|
||||
|
||||
if (!_anchorPointInPoints.equals(Vec2::ZERO))
|
||||
if (!_anchorPointInPoints.isZero())
|
||||
{
|
||||
x += ((c * -_anchorPointInPoints.x * _scaleX) + (-s * -_anchorPointInPoints.y * _scaleY));
|
||||
y += ((s * -_anchorPointInPoints.x * _scaleX) + (c * -_anchorPointInPoints.y * _scaleY));
|
||||
|
|
|
@ -36,6 +36,10 @@ using namespace Windows::UI::Xaml::Input;
|
|||
using namespace Windows::UI::Xaml::Media;
|
||||
using namespace Windows::UI::Xaml::Navigation;
|
||||
|
||||
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
||||
using namespace Windows::Phone::UI::Input;
|
||||
#endif
|
||||
|
||||
OpenGLESPage::OpenGLESPage() :
|
||||
OpenGLESPage(nullptr)
|
||||
{
|
||||
|
@ -76,6 +80,7 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) :
|
|||
|
||||
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
||||
Windows::UI::ViewManagement::StatusBar::GetForCurrentView()->HideAsync();
|
||||
HardwareButtons::BackPressed += ref new EventHandler<BackPressedEventArgs^>(this, &OpenGLESPage::OnBackButtonPressed);
|
||||
#else
|
||||
// Disable all pointer visual feedback for better performance when touching.
|
||||
// This is not supported on Windows Phone applications.
|
||||
|
@ -163,6 +168,21 @@ void OpenGLESPage::OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Wi
|
|||
}
|
||||
}
|
||||
|
||||
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
||||
void OpenGLESPage::OnBackButtonPressed(Object^ sender, BackPressedEventArgs^ args)
|
||||
{
|
||||
bool myAppCanNavigate = false;
|
||||
if (myAppCanNavigate)
|
||||
{
|
||||
args->Handled = true;
|
||||
}
|
||||
else {
|
||||
// Do nothing. Leave args->Handled set to the current value, false.
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void OpenGLESPage::OnSwapChainPanelSizeChanged(Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e)
|
||||
{
|
||||
// Size change events occur outside of the render thread. A lock is required when updating
|
||||
|
@ -283,6 +303,11 @@ void OpenGLESPage::StartRenderLoop()
|
|||
{
|
||||
m_deviceLost = true;
|
||||
|
||||
if (m_renderer)
|
||||
{
|
||||
m_renderer->Pause();
|
||||
}
|
||||
|
||||
// XAML objects like the SwapChainPanel must only be manipulated on the UI thread.
|
||||
swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([=]()
|
||||
{
|
||||
|
@ -292,6 +317,11 @@ void OpenGLESPage::StartRenderLoop()
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_renderer)
|
||||
{
|
||||
m_renderer->Pause();
|
||||
}
|
||||
});
|
||||
|
||||
// Run task on a dedicated high priority background thread.
|
||||
|
@ -305,9 +335,4 @@ void OpenGLESPage::StopRenderLoop()
|
|||
mRenderLoopWorker->Cancel();
|
||||
mRenderLoopWorker = nullptr;
|
||||
}
|
||||
|
||||
if (m_renderer)
|
||||
{
|
||||
m_renderer->Pause();
|
||||
}
|
||||
}
|
|
@ -39,6 +39,9 @@ namespace cocos2d
|
|||
void OnPageLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
|
||||
void OnSwapChainPanelSizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e);
|
||||
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
||||
void OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args);
|
||||
#endif
|
||||
void GetSwapChainPanelSize(GLsizei* width, GLsizei* height);
|
||||
void CreateRenderSurface();
|
||||
void DestroyRenderSurface();
|
||||
|
|
Loading…
Reference in New Issue