Hello,
I have a question about the actions, when i use a “CallFunc” Action like this :
cocos2d::CallFunc * func1 = cocos2d::CallFunc::create(=->void{
sprite->setPosition(0,0);
}) ;
actions.pushBack(func1) ;
auto sequence = Sequence::create(actions);
sprite->runAction(sequence) ;
If i run that, my sprite in the position (x = 500, y = 500) pass suddenly in the new position (x = 0 ; y = 0).
How can i make for the transition between the old position (x = 500, y = 500) and the new position (x = 0, y = 0) during like 5 seconds and make a move transition. I know i can do that with a MoveTo or a MoveBy but i want to know if its possible with using only CallFunc.
Thanks,
That’s what MoveTo/By is for? Are you trying to do something extra? or different? It would be better to subclass ActionInterval or MoveTo instead of trying to use CallFunc.
1 Like
Thanks for your answer, yes of course, its for do other things like for example move a SpotLight from x,y,z position to x,y,z position around a Sprite3d without use “Update(float delta) method” like this : 
void HelloWorld::update(float delta){
float z = lampe->getDirection().z;
if (eclipse == ECLIPSE::DEMARRE)
{
z += (delta *1.f) ;
if (z >= 1.f)
eclipse = ECLIPSE::RETOUR ;
}
else if (eclipse == ECLIPSE::RETOUR)
{
z -= (delta *1.f) ;
if (z <= -0.57f)
eclipse = ECLIPSE::STOP ;
}
lampe->setDirection(Vec3(lampe->getDirection().x ,
lampe->getDirection().y,
z));
}
Look like MoveBy class use the same way of do the things :
class CC_DLL MoveBy : public ActionInterval
{
public:
/**
* Creates the action.
*
* @param duration Duration time, in seconds.
* @param deltaPosition The delta distance in 2d, it’s a Vec2 type.
* @return An autoreleased MoveBy object.
/
static MoveBy create(float duration, const Vec2& deltaPosition);
etc…
virtual void update(float time) override;
etc…
};
Well it looks like you’ve already solved it then. You can encapsulate this into a subclass of ActionInterval and submit it as a PR to add it into the core engine 
1 Like
Yep, the Actions all just have some internal state that might make your update method a little shorter, but otherwise it’s effectively the same thing, just wrapped up in a nice encapsulation where you can just supply duration+Position and it handles the rest.
That way if you want to use this in multiple places you could just create a MoveLightAroundPointAction instead of writing the update method everywhere. Maybe the action takes a delta vec3, so you could have it change x, y, or z, or all three during the update.
1 Like
Ah ok very nice, thanks a lot for you help 