CCFrameData *CCTween::tweenNodeTo(float percent, CCFrameData *node) { node = node == NULL ? m_pTweenData : node; if (!m_pFrom->isTween) { percent = 0; } node->x = m_pFrom->x + percent * m_pBetween->x; node->y = m_pFrom->y + percent * m_pBetween->y; node->scaleX = m_pFrom->scaleX + percent * m_pBetween->scaleX; node->scaleY = m_pFrom->scaleY + percent * m_pBetween->scaleY; node->skewX = m_pFrom->skewX + percent * m_pBetween->skewX; node->skewY = m_pFrom->skewY + percent * m_pBetween->skewY; m_pBone->setTransformDirty(true); if (node && m_pBetween->isUseColorInfo) { tweenColorTo(percent, node); } return node; }
FrameData *Tween::tweenNodeTo(float percent, FrameData *node) { node = node == nullptr ? _tweenData : node; if (!_from->isTween) { percent = 0; } node->x = _from->x + percent * _between->x; node->y = _from->y + percent * _between->y; node->scaleX = _from->scaleX + percent * _between->scaleX; node->scaleY = _from->scaleY + percent * _between->scaleY; node->skewX = _from->skewX + percent * _between->skewX; node->skewY = _from->skewY + percent * _between->skewY; _bone->setTransformDirty(true); if (node && _between->isUseColorInfo) { tweenColorTo(percent, node); } return node; }
//------------------------------------------------------------------------------------------------------------------------------------- // void Tweenable2D::updateTweening() { float tmpSec = timer.elapsedSec(); // Position if( posTweenProps.active ) { posTweenProps.update( tmpSec ); } else { if ( posTweenProps.backWhenDone ) { tweenPosTo(posTweenProps.startX, posTweenProps.startY, posTweenProps.tweenTime, posTweenProps.easeType, false ); } } // Size if( sizeTweenProps.active ) { sizeTweenProps.update( tmpSec ); } else { if ( sizeTweenProps.backWhenDone ) { tweenSizeTo(sizeTweenProps.startX, sizeTweenProps.startY, sizeTweenProps.tweenTime, sizeTweenProps.easeType, false ); } } // Alpha if( alphaTweenProps.active ) { alphaTweenProps.update( tmpSec ); } else { if ( alphaTweenProps.backWhenDone ) { tweenAlphaTo(alphaTweenProps.startX, alphaTweenProps.tweenTime, alphaTweenProps.easeType, false ); } } // Angle if( angleTweenProps.active ) { angleTweenProps.update( tmpSec ); //angle = AngleMath::wrapAngle180( angle ); if( angle > 180.0f ) { angle -= 360.0f; } else if ( angle < -180.0f ) { angle += 360.0f; } } else { if ( angleTweenProps.backWhenDone ) { tweenAngleTo(angleTweenProps.startX, angleTweenProps.tweenTime, angleTweenProps.easeType, false ); } } // Color if( colorTweenProps.active ) { colorTweenProps.update( tmpSec ); //AColor tmpCol = colorInterpolator.interpolateAlphaBlendingRGB( colorTweeningVal ); //color.setRGB( tmpCol.rgb.red, tmpCol.rgb.green, tmpCol.rgb.blue ); interpolateAlphaBlendingRGB( &startColor, &endColor, colorTweeningVal, &color ); color.a = alpha; //cout << color << endl; } else { if ( colorTweenProps.backWhenDone ) { //AColor tmpCol( endColor.rgb.red, endColor.rgb.green, endColor.rgb.blue ); //tweenColorTo( &tmpCol, colorTweenProps.tweenTime, colorTweenProps.easeType, false ); tweenColorTo( endColor, colorTweenProps.tweenTime, colorTweenProps.easeType, false ); } } }