looking at MotionStreakTest.cpp

looking at MotionStreakTest.cpp
0.0 0


void MotionStreakTest1::onEnter()

CCActionInterval colorAction = CCRepeatForever::createCCSequence::create(
Why not make CCSequence::create return a CCActionInterval
instead of CCFiniteTimeAction* if you are going to do that?
You are casting in the wrong direction. It may work but it sure violate the inheritance tree.

The two fields
float m_elapsed;
bool m_bFirstTick;
in CCActionInterval do not exist in CCFiniteTimeAction.
This is asking for trouble.


Is there a reason why you could not implement a CCActionInterval:create(CCArray arrayOfActions) instead which returns a CCActionInterval.
I am just looking around so I do not understand the flow yet but this look very suspicious.



You can refer to the implementation of CCSequence, it will return a pointer type of the parameter.
And the pointer type of parameter is CCFiniteTimeAction*.


Yes it returns CCFiniteTimeAction* which is casted to CCActionInterval *

this casting is WRONG

Look at CCActionInterval documentation

CCCopying … CCOBJect … CCAction …CCFiniteTimeAction … CCActionInterval

you should not cast from CCFiniteTimeAction to CCActionInterval.

References to field like m_bFirstTick and m_elapsed using this pointer are illegal and could damage memory.
They cannot be detected by the compiler because of the arbitrary cast.



To be noted as I mentioned in the toLua thread:


class CCActionInterval : public CCAction
class CCFiniteTimeAction : public CCActionInterval

instead of
class CCActionInterval : public CCFiniteTimeAction
class CCFiniteTimeAction : public CCAction

so maybe this was a last minute change and someone added the casting to force it to work.