本文整理汇总了C++中ActionManager::addAction方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionManager::addAction方法的具体用法?C++ ActionManager::addAction怎么用?C++ ActionManager::addAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionManager
的用法示例。
在下文中一共展示了ActionManager::addAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addPipe
void Pipe::addPipe(float dt)
{
SpriteFrameCache *pFrameCache = SpriteFrameCache::getInstance();
auto pipe_up = Sprite::createWithSpriteFrame(pFrameCache->getSpriteFrameByName("pipe_up.png"));
pipe_up->setPosition(Point(pipe_up->getContentSize().width/2,pipe_up->getContentSize().height/2));
auto body_up=PhysicsBody::create();
auto body_shape_up=PhysicsShapeBox::create(pipe_up->getContentSize());
body_up->addShape(body_shape_up);
body_up->setDynamic(false);
body_up->setGravityEnable(false);
body_up->setCategoryBitmask(1);
body_up->setCollisionBitmask(-1);
body_up->setContactTestBitmask(-1);
pipe_up->setPhysicsBody(body_up);
//向下管道初始化,这边的THROUGH_HEIGHT是两根管道之间的空隙
auto pipe_down = Sprite::createWithSpriteFrame(pFrameCache->getSpriteFrameByName("pipe_down.png"));
pipe_down->setPosition(Point(pipe_down->getContentSize().width/2,pipe_down->getContentSize().height/2+pipe_up->getContentSize().height+THROUGH_HEIGHT));
auto body_down=PhysicsBody::create();
auto body_shape_down=PhysicsShapeBox::create(pipe_down->getContentSize());
body_down->addShape(body_shape_down);
body_down->setDynamic(false);
body_down->setGravityEnable(false);
body_down->setCategoryBitmask(1);
body_down->setCollisionBitmask(-1);
body_down->setContactTestBitmask(-1);
pipe_down->setPhysicsBody(body_down);
//这边的node相当于一个容器把这两个管道封装在一个节点中并设置target
auto node=Node::create();
node->addChild(pipe_up,0,PIPE_UP);
node->addChild(pipe_down,0,PIPE_DOWN);
node->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
//关于管道Y坐标的设置(就是管道上下长度不一样的处理),大家还是看图例,说不清楚
//管道是从右边移动到左边,所以PIPE_X的值肯定比游戏的width要大这里设定是300
int range=rand()%PIPE_RANGE;
node->setPosition(Point(PIPE_X, PIPE_Y + range));
ActionManager *pActionManager = Director::getInstance()->getActionManager();
MoveBy *pMoveBy = MoveBy::create(3.2f, Point(-400, 0));
CallFuncN *pMoveOverCallback = CallFuncN::create(CC_CALLBACK_1(Pipe::moveOverHandle, this));
ActionInterval *pSeq = Sequence::create(pMoveBy, pMoveOverCallback, nullptr);
pActionManager->addAction(pSeq, node, false);
this->addChild(node);
pPipeVector.pushBack(node);
if (isStart) {
scheduleUpdate();
isStart = false;
}
}