本文整理汇总了C++中ccpLength函数的典型用法代码示例。如果您正苦于以下问题:C++ ccpLength函数的具体用法?C++ ccpLength怎么用?C++ ccpLength使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ccpLength函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hitTestStripRound
HitTestResult* hitTestStripRound(StripBodyNode* a, RoundBodyNode* b)
{
Point cb = b->getCenter();
float rb = b->getRadius();
Point ca = a->getCenter();
Vector2 ava = a->getEnd() - a->getBegin();
float ha = a->getWidth();
float wa = ccpLength(ava);
float ra = a->getRadius();
Point rrp;
ava = ava/wa;
bool hit = isRoundCrossRect(cb, rb, ca, wa, ha, ava);
if(hit)
{
Point hp;
float distance;
Point ba = a->getBegin();
Vector2 delta = ba - cb;
float deltaLength = ccpLength(delta);
hp = cb + delta/deltaLength * rb;
distance = deltaLength - rb;
return HitTestResult::create(HTRT_CROSS, hp, distance);
}
else
{
return HitTestResult::create(HTRT_NONE);
}
}
示例2: update
void AniNode::update(float delta)
{
if (ccpLength(aniNode_moveSpeed) != 0 || ccpLength(aniNode_accMoveSpeed) != 0) {
CCPoint dis = ccpAdd(ccpMult(aniNode_moveSpeed, delta), ccpMult(aniNode_accMoveSpeed, 0.5 * delta * delta));
this->setPosition(ccpAdd(this->getPosition(), dis));
aniNode_moveSpeed = ccpAdd(aniNode_moveSpeed, ccpMult(aniNode_accMoveSpeed, delta));
}
if (aniNode_rotateSpeed != 0 || aniNode_accRotateSpeed != 0) {
float rot = aniNode_rotateSpeed * delta + 0.5 * aniNode_accRotateSpeed * delta * delta;
this->setRotation(this->getRotation() + rot);
aniNode_rotateSpeed = aniNode_rotateSpeed + aniNode_accRotateSpeed * delta;
}
}
示例3: originalVertex
void CCTwirl::update(float time)
{
int i, j;
CCPoint c = m_position;
for (i = 0; i < (m_sGridSize.width+1); ++i)
{
for (j = 0; j < (m_sGridSize.height+1); ++j)
{
ccVertex3F v = originalVertex(ccp(i ,j));
CCPoint avg = ccp(i-(m_sGridSize.width/2.0f), j-(m_sGridSize.height/2.0f));
float r = ccpLength(avg);
float amp = 0.1f * m_fAmplitude * m_fAmplitudeRate;
float a = r * cosf( (float)M_PI/2.0f + time * (float)M_PI * m_nTwirls * 2 ) * amp;
CCPoint d = ccp(
sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x),
cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x));
v.x = c.x + d.x;
v.y = c.y + d.y;
setVertex(ccp(i ,j), v);
}
}
}
示例4: originalVertex
void CCTwirl::update(ccTime time)
{
int i, j;
CCPoint c = m_positionInPixels;
for (i = 0; i < (m_sGridSize.x+1); ++i)
{
for (j = 0; j < (m_sGridSize.y+1); ++j)
{
ccVertex3F v = originalVertex(ccg(i ,j));
CCPoint avg = ccp(i-(m_sGridSize.x/2.0f), j-(m_sGridSize.y/2.0f));
CGFloat r = ccpLength(avg);
CGFloat amp = 0.1f * m_fAmplitude * m_fAmplitudeRate;
CGFloat a = r * cosf( (CGFloat)M_PI/2.0f + time * (CGFloat)M_PI * m_nTwirls * 2 ) * amp;
CCPoint d;
d.x = sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x);
d.y = cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x);
v.x = c.x + d.x;
v.y = c.y + d.y;
setVertex(ccg(i ,j), v);
}
}
}
示例5: hitTestRectRound
HitTestResult* hitTestRectRound(RectBodyNode* a, RoundBodyNode* b)
{
Point ca = a->getCenter();
float wa = a->getWidth();
float ha = a->getHeight();
float aa = CC_DEGREES_TO_RADIANS(-a->getAngle());
float ra = a->getRadius();
Point cb = b->getCenter();
float rb = b->getRadius();
bool hit = isRoundCrossRect(cb, rb, ca, wa, ha, ccpForAngle(aa));
if(hit)
{
Point hp;
float distance;
Vector2 delta = ca - cb;
float deltaLength = ccpLength(delta);
hp = cb + delta/deltaLength * rb;
distance = deltaLength - rb;
return HitTestResult::create(HTRT_CROSS, hp, distance);
}
else
{
return HitTestResult::create(HTRT_NONE);
}
}
示例6: ccpLength
void BWCircleBy::startWithTarget(CCNode *pTarget)
{
BWActionInterval::startWithTarget(pTarget);
m_previousPosition = m_startPosition = pTarget->getPosition();
float fDis = ccpLength(m_dirPoint);
m_fA = fDis*0.5;
}
示例7: ccpLength
void CCMoveAccelBy::calcAccel()
{
//all scalars: s a v t
float t = m_fDuration;
s = ccpLength( m_delta );
a = (s - v * t) / (0.5f * t * t);
}
示例8: ccpLength
void Solider::setTarget(CCPoint _target)
{
m_ID = MOVE;
timeMove = 0;
m_targetPos = _target;
timeFinishMove = ccpLength(ccpSub(m_targetPos, m_pos))/ m_maxVelocity/60;
}
示例9: ccpLength
void CircleBy::startWithTarget(CCNode *pTarget)
{
ActionInterval::startWithTarget(pTarget);
m_startPosition = pTarget->getPosition();
float fDistance = ccpLength(m_dirPoint);
m_fA = fDistance * 0.5;
}
示例10: setPosition
void LFTwirl::preCalculateDistance()
{
setPosition(m_pTarget->getPosition());
// gridDistanceArray = new float[ (m_sGridSize.x + 1) * (m_sGridSize.y + 1) ];
//Richard
// 原先类型为int 现在CCSize为float 墙砖为int
gridDistanceArray = new float[ ((int)m_sGridSize.width + 1) * ((int)m_sGridSize.height + 1) ];
int i, j;
int index = 0;
for (i = 0; i < m_sGridSize.width + 1; ++i)
{
for (j = 0; j < m_sGridSize.height + 1; ++j)
{
ccVertex3F v = originalVertex(ccp(i, j));
CCPoint relativedPos = ccp(v.x - m_position.x,v.y - m_position.y);
float dis = ccpLength(relativedPos) + 1.0f;
gridDistanceArray[index] = dis;
index ++;
}
}
// setPosition(m_pTarget->getPosition());
}
示例11: ccpSub
void CCCurl::startWithTarget(CCNode* pTarget) {
CCActionInterval::startWithTarget(pTarget);
// get start radius
CCPoint v = ccpSub(pTarget->getPosition(), m_center);
m_fromRadius = ccpLength(v);
m_initAngle = v.getAngle();
}
示例12: ccpSub
//--------------------------------------------------------------------
void FKCW_Action_Curl::startWithTarget(CCNode* pTarget)
{
CCActionInterval::startWithTarget(pTarget);
// 获取起始半径和角度
CCPoint v = ccpSub(pTarget->getPosition(), m_center);
m_fromRadius = ccpLength(v);
m_initAngle = v.getAngle();
}
示例13: ccpLength
void CCLayerGradient::updateColor()
{
CCLayerColor::updateColor();
float h = ccpLength(m_AlongVector);
if (h == 0)
return;
double c = sqrt(2.0);
CCPoint u = ccp(m_AlongVector.x / h, m_AlongVector.y / h);
// Compressed Interpolation mode
if (m_bCompressedInterpolation)
{
float h2 = 1 / ( fabsf(u.x) + fabsf(u.y) );
u = ccpMult(u, h2 * (float)c);
}
float opacityf = (float)m_cOpacity / 255.0f;
ccColor4B S = {
(unsigned char) m_tColor.r,
(unsigned char) m_tColor.g,
(unsigned char) m_tColor.b,
(unsigned char) (m_cStartOpacity * opacityf)
};
ccColor4B E = {
(unsigned char) m_endColor.r,
(unsigned char) m_endColor.g,
(unsigned char) m_endColor.b,
(unsigned char) (m_cEndOpacity * opacityf)
};
// (-1, -1)
m_pSquareColors[0].r = (GLubyte) (E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c)));
m_pSquareColors[0].g = (GLubyte) (E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0f * c)));
m_pSquareColors[0].b = (GLubyte) (E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0f * c)));
m_pSquareColors[0].a = (GLubyte) (E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0f * c)));
// (1, -1)
m_pSquareColors[1].r = (GLubyte) (E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0f * c)));
m_pSquareColors[1].g = (GLubyte) (E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0f * c)));
m_pSquareColors[1].b = (GLubyte) (E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0f * c)));
m_pSquareColors[1].a = (GLubyte) (E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0f * c)));
// (-1, 1)
m_pSquareColors[2].r = (GLubyte) (E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0f * c)));
m_pSquareColors[2].g = (GLubyte) (E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0f * c)));
m_pSquareColors[2].b = (GLubyte) (E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0f * c)));
m_pSquareColors[2].a = (GLubyte) (E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0f * c)));
// (1, 1)
m_pSquareColors[3].r = (GLubyte) (E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0f * c)));
m_pSquareColors[3].g = (GLubyte) (E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0f * c)));
m_pSquareColors[3].b = (GLubyte) (E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0f * c)));
m_pSquareColors[3].a = (GLubyte) (E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c)));
}
示例14: ccpLength
void CGradientView::updateColor()
{
CColorView::updateColor();
float h = ccpLength(m_tAlongVector);
if( (int)h == 0 )
return;
float c = sqrtf(2.0f);
CCPoint u = CCPoint(m_tAlongVector.x / h, m_tAlongVector.y / h);
// Compressed Interpolation mode
if( m_bCompressedInterpolation )
{
float h2 = 1 / ( fabsf(u.x) + fabsf(u.y) );
u = ccpMult(u, h2 * (float)c);
}
float opacityf = (float)_displayedOpacity / 255.0f;
ccColor4F S = {
_displayedColor.r / 255.0f,
_displayedColor.g / 255.0f,
_displayedColor.b / 255.0f,
m_cStartOpacity * opacityf / 255.0f
};
ccColor4F E = {
m_tEndColor.r / 255.0f,
m_tEndColor.g / 255.0f,
m_tEndColor.b / 255.0f,
m_cEndOpacity * opacityf / 255.0f
};
// (-1, -1)
m_pSquareColors[0].r = E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c));
m_pSquareColors[0].g = E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0f * c));
m_pSquareColors[0].b = E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0f * c));
m_pSquareColors[0].a = E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0f * c));
// (1, -1)
m_pSquareColors[1].r = E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0f * c));
m_pSquareColors[1].g = E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0f * c));
m_pSquareColors[1].b = E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0f * c));
m_pSquareColors[1].a = E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0f * c));
// (-1, 1)
m_pSquareColors[2].r = E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0f * c));
m_pSquareColors[2].g = E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0f * c));
m_pSquareColors[2].b = E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0f * c));
m_pSquareColors[2].a = E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0f * c));
// (1, 1)
m_pSquareColors[3].r = E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0f * c));
m_pSquareColors[3].g = E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0f * c));
m_pSquareColors[3].b = E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0f * c));
m_pSquareColors[3].a = E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c));
}
示例15: CC_UNUSED_PARAM
void CCLens3D::update(ccTime time)
{
CC_UNUSED_PARAM(time);
if (m_bDirty)
{
int i, j;
for (i = 0; i < m_sGridSize.x + 1; ++i)
{
for (j = 0; j < m_sGridSize.y + 1; ++j)
{
ccVertex3F v = originalVertex(ccg(i, j));
CCPoint vect = ccpSub(m_positionInPixels, ccp(v.x, v.y));
CGFloat r = ccpLength(vect);
if (r < m_fRadius)
{
r = m_fRadius - r;
CGFloat pre_log = r / m_fRadius;
if ( pre_log == 0 )
{
pre_log = 0.001f;
}
float l = logf(pre_log) * m_fLensEffect;
float new_r = expf( l ) * m_fRadius;
if (ccpLength(vect) > 0)
{
vect = ccpNormalize(vect);
CCPoint new_vect = ccpMult(vect, new_r);
v.z += ccpLength(new_vect) * m_fLensEffect;
}
}
setVertex(ccg(i, j), v);
}
}
m_bDirty = false;
}
}