I am trying to get the following code running
Vec2 buffer = Vec2((width / 2) / 3.5, (height / 2) / 3.5);
Vec2 b1 = Vec2(width / 5, height / 5);
Vec2 b2 = Vec2(width - buffer.x, height - buffer.y);
auto p1x = MoveBy::create(9, b1);
auto p2x = MoveBy::create(9, b2);
auto p1 = EaseInOut::create(p1x->clone());
auto p2 = EaseInOut::create(p2x->clone());
auto seq = Sequence::create(p1, p2, nullptr);
auto seqf = RepeatForever::create(seq->clone());
diagonal->runAction(seqf);
diagonal->setPosition(Vec2(width / 2, height / 2));
However the compiler simply states "no matching function for call to ‘cocos2d::EaseInOUt::create(cocos2d::MoveBy*)’.
Why are you cloning p1x when you don’t use it?
why not:
auto p1x = MoveBy::create(9, b1);
auto p2x = MoveBy::create(9, b2);
auto p1 = EaseInOut::create(p1x);
auto p2 = EaseInOut::create(p2x);
same thing with your seq you create it and clone it when using it?
The documentation said ->clone() So I assumed it was necessary. In the end I am just trying to create a loop between the two points that is eased and repeats forever.
The code you posted caused "no mathing function for call to ‘cocos2d::EaseINOUt::create(cocos2d::MoveBy*&)’, auto p1 = EaseInOUt::create(p1x);
I wasn’t trying to fix your code. I was trying to point out that you don’t need to clone() it, with how your code was.
Where did the docs say ->clone() it?
I wrote that chapter. Notice clone() is at the very end. You don’t use it except for a specific reason.
Clone is exactly like it sounds. If you have an Action, you can apply it to multiple Node objects by using clone()
OK, looks like I do not need clone anyways then. Why isnt this compiling then?
auto p1x = MoveBy::create(9, b1);
auto p2x = MoveBy::create(9, b2);
auto p1 = EaseInOut::create(p1x);
auto p2 = EaseInOut::create(p2x);
Do I need to somehow convert p1x to a more generic type?
Looking at the API-doc for EaseInOut, there isn’t a matching constructor for what you are doing.
The API doc says:
static EaseInOut * create (ActionInterval *action, float rate)
and you are doing:
EaseInOut::create(p1x);
you are missing the rate parameter.
1 Like
I cant believe I didnt see that in the compiler. Thankyou!