A way to fadeIn from a certain value

A way to fadeIn from a certain value
0.0 0


I want to know if there is a way to create a fadeIn animation which begins from a certain value of opacity greater than 0. Default fadeIn animation modifies the opacity from 0 to 255, but I need an animation that goes from 10 to 255 for example.


Ok I found a way by extending the CCFadeIn class and overriding the update() method

class CCFadeInRange : public CCFadeIn
    CCFadeInRange(int from, int to) : from(from), to(to){};
    virtual void update(float time);

    /** creates the action */
    static CCFadeInRange* create(float d, int from, int to);

    int from;
    int to;

CCFadeInRange* CCFadeInRange::create(float d, int from, int to)
    CCFadeInRange* pAction = new CCFadeInRange(from, to);


    return pAction;

//CCFadeIn with range
void CCFadeInRange::update(float time)
    CCRGBAProtocol *pRGBAProtocol = dynamic_cast(m_pTarget);
    if (pRGBAProtocol)
        pRGBAProtocol->setOpacity(from + (GLubyte)((to - from) * time));


You should use CCFadeTo : “It modifies the opacity from the current value to a custom one.”
Set the opacity to 10, then fade to 255.


You’re right, i should use that, thx