Create sprite after period :(

Create sprite after period :(
0

#1

I have the code

    bl = Sprite::create("bl.png");
	bl->setPosition(sp->getPosition());
	this->addChild(bl);
	auto moveBy = MoveBy::create(2, Vec2(0, 500));
	bl->runAction(moveBy);

How to make the following code repeated after a period of time ??.
I would like to have a sprite like this one after each period.
sorry for my english :frowning:
thank you. !!!


#2

You could create an scheduler like this:

Director::getInstance()->getScheduler()->schedule(SEL_SCHEDULE(&Game::moveAutoMethod), Game::getInstance(), 0.45f, false);

0.45f is the period time.
And Game::moveAutoMethod is the method that should contain the MoveBy.
Advice: Make sure to configure different names in each sprite… using bl->setName


#3

Or use Repeat or RepeatForever

http://docs.cocos2d-x.org/api-ref/cplusplus/v3x/df/d05/classcocos2d_1_1_repeat.html

General docs on Actions: http://docs.cocos2d-x.org/cocos2d-x/en/actions/