• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ccpLength函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ccpLength函数的典型用法代码示例。如果您正苦于以下问题:C++ ccpLength函数的具体用法?C++ ccpLength怎么用?C++ ccpLength使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ccpLength函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
        }
    }
开发者ID:Glede,项目名称:U87STGEngine,代码行数:29,代码来源:U87Geometry.cpp


示例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;
    }    
    
}
开发者ID:Michael-Z,项目名称:MyBird,代码行数:15,代码来源:AniNode.cpp


示例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);
        }
    }
}
开发者ID:holybomb,项目名称:PinyinFight,代码行数:28,代码来源:CCActionGrid3D.cpp


示例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);
			}
		}
	}
开发者ID:amatuer,项目名称:cocos2d-game,代码行数:29,代码来源:CCActionGrid3D.cpp


示例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);
        }
    }
开发者ID:Glede,项目名称:U87STGEngine,代码行数:26,代码来源:U87Geometry.cpp


示例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;
}
开发者ID:sanyuancap,项目名称:Game_----BWBizerAction,代码行数:7,代码来源:BWActionInterval.cpp


示例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);
}
开发者ID:korman,项目名称:Temp,代码行数:7,代码来源:CCActionMoveAccel.cpp


示例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;
}
开发者ID:kienchochethahaha,项目名称:game-luan-van,代码行数:7,代码来源:Solider.cpp


示例9: ccpLength

void CircleBy::startWithTarget(CCNode *pTarget)
{
    ActionInterval::startWithTarget(pTarget);
    m_startPosition = pTarget->getPosition();
    float fDistance = ccpLength(m_dirPoint);
    m_fA = fDistance * 0.5;
}
开发者ID:253627764,项目名称:----Cocos2dx-MVC-,代码行数:7,代码来源:ActionInterval.cpp


示例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());

}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:25,代码来源:LFActionGrid3D.cpp


示例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();
}
开发者ID:Ratel13,项目名称:cocos2dx-better,代码行数:8,代码来源:CCCurl.cpp


示例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();
}
开发者ID:duzhi5368,项目名称:FKCocos2dxWrapper_2.x,代码行数:10,代码来源:FKCW_Action_Curl.cpp


示例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)));
}
开发者ID:Basingse,项目名称:cocos2d-x,代码行数:55,代码来源:CCLayer.cpp


示例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));
}
开发者ID:54993306,项目名称:Classes,代码行数:55,代码来源:GradientView.cpp


示例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;
		}
	}
开发者ID:amatuer,项目名称:cocos2d-game,代码行数:42,代码来源:CCActionGrid3D.cpp


示例16: CC_UNUSED_PARAM

void CCLens3D::update(float time)
{
    CC_UNUSED_PARAM(time);
    if (m_bDirty)
    {
        int i, j;
        
        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 vect = ccpSub(m_tPoint, ccp(v.x, v.y));
                float r = ccpLength(vect);
                
                if (r < m_fRadius)
                {
                    r = m_fRadius - r;
                    float 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 += (m_bConcave ? -1.0f : 1.0f) * ccpLength(new_vect) * m_fLensEffect;
                    }
                }
                
                setVertex(ccp(i, j), v);
            }
        }
        
        m_bDirty = false;
    }
}
开发者ID:anarki1234,项目名称:9miao,代码行数:42,代码来源:CCActionGrid3D.cpp


示例17: MIN

void CCBigImage::setPosition(const CCPoint &newPosition)
{
	float significantPositionDelta = MIN(this->_screenLoadRectExtension.width,
										   this->_screenLoadRectExtension.height) / 2.0f;
	
	if ( ccpLength(ccpSub(newPosition, this->getPosition())) > significantPositionDelta ) {
		this->_significantPositionChange = true;
    }
    
    CCNode::setPosition(newPosition);
}
开发者ID:DPigpen,项目名称:cocos2dx_recipe,代码行数:11,代码来源:CCBigImage.cpp


示例18: calculateCosASinAOfVec1ToVec2

CCPoint calculateCosASinAOfVec1ToVec2(const CCPoint&vec1,const CCPoint&vec2)
//return {cos(vec1,vec2),sin(vec1,vec2)}
{
    float cosA=ccpDot(vec1, vec2)/(ccpLength(vec1)*ccpLength(vec2));
    float signalOfSinA;
    {
        float _vec1[3]={vec1.x,vec1.y,0};
        float _vec2[3]={vec2.x,vec2.y,0};
        float _rs[3];
        __cross(_vec1, _vec2, _rs);
        if (_rs[2]==0) {
            signalOfSinA=0;
        }else if(_rs[2]>0){
            signalOfSinA=1;
        }else{
            signalOfSinA=-1;
        }
    }
    float sinA=signalOfSinA*sqrtf(MAX(0,1-cosA*cosA));
    return CCPoint(cosA,sinA);
}
开发者ID:fordream,项目名称:HappyGame,代码行数:21,代码来源:ensMath.cpp


示例19: ccpLength

	void CCMotionStreak::update(ccTime delta)
	{
		CCPoint location = this->convertToWorldSpace(CCPointZero);
		m_pRibbon->setPosition(ccp(-1*location.x, -1*location.y));
		float len = ccpLength(ccpSub(m_tLastLocation, location));
		if (len > m_fSegThreshold)
		{
			m_pRibbon->addPointAt(location, m_fWidth);
			m_tLastLocation = location;
		}
		m_pRibbon->update(delta);
	}
开发者ID:LiangYue1981816,项目名称:CrossEngine,代码行数:12,代码来源:CCMotionStreak.cpp


示例20: hitTestStripStrip

    HitTestResult* hitTestStripStrip(StripBodyNode* a, StripBodyNode* b)
    {
        Point Atop[4];
        Point Btop[4];
        a->getTops(Atop, Atop + 1, Atop + 2, Atop + 3);
        b->getTops(Btop, Btop + 1, Btop + 2, Btop + 3);
        int cpcount = 0;
        Point cp[12];
        bool hit = isRectCrossRect(Atop[0], Atop[1], Atop[2], Atop[3],
            Btop[0], Btop[1], Btop[2], Btop[3], &cpcount, cp);

        if(hit)
        {
            if(cpcount < 0)
                cpcount = 0;

            Point ca = a->getCenter();
            float wa = a->getWidth();
            float ha = ccpDistance(a->getBegin(), a->getEnd());
            Vector2 aa = ccpNormalize(a->getEnd() - a->getBegin());
            for(int i = 0; i < 4; i++)
            {
                if(isPointInRect(Btop[i], ca, wa, ha, aa))
                {
                    cp[cpcount++] = Btop[i];
                }
            }

            // use dot result for comparing directly
            // get true distance when receive a minimun dot result
            int iMin = 0;
            float dMin = 0;
            Vector2 direction = a->getEnd() - a->getBegin();
            for(int i = 0; i < cpcount; i++)
            {
                float d = ccpDot(cp[i], direction);
                if( i == 0 && d < dMin)
                {
                    dMin = d;
                    iMin = i;
                }
            }

            dMin /= ccpLength(direction);
            return HitTestResult::create(HTRT_CROSS, cp[iMin], dMin);
        }
        else
        {
            return HitTestResult::create(HTRT_NONE);
        }
    }
开发者ID:Glede,项目名称:U87STGEngine,代码行数:51,代码来源:U87Geometry.cpp



注:本文中的ccpLength函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ccprintf函数代码示例发布时间:2022-05-30
下一篇:
C++ ccpAdd函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap