本文整理汇总了C++中PointArray::addControlPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ PointArray::addControlPoint方法的具体用法?C++ PointArray::addControlPoint怎么用?C++ PointArray::addControlPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointArray
的用法示例。
在下文中一共展示了PointArray::addControlPoint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: p
PointArray *MainScene::walkableAdjacentTilesCoordForTileCoord(const Point &tileCoord)
{
PointArray *tmp = PointArray::create(8);
Point p(tileCoord.x, tileCoord.y - 1);
if (this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
}
p.setPoint(tileCoord.x - 1, tileCoord.y);
if (this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
}
p.setPoint(tileCoord.x, tileCoord.y + 1);
if (this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
}
p.setPoint(tileCoord.x + 1, tileCoord.y);
if (this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
}
//
p.setPoint(tileCoord.x + 1, tileCoord.y + 1);
if (this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
}
p.setPoint(tileCoord.x + 1, tileCoord.y - 1);
if (this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
}
p.setPoint(tileCoord.x - 1, tileCoord.y - 1);
if (this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
}
p.setPoint(tileCoord.x - 1, tileCoord.y + 1);
if (this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
}
//
return tmp;
}
示例2: Point
cocos2d::PointArray * AStarPathHelper::checkFourDirection(AStarPathUnit * unit)
{
PointArray* arr = PointArray::create(4);
Point tileCoord = unit->getTileCoord();
// right
Point nextPoint = Point(tileCoord.x + 1, tileCoord.y);
if (_layer->getMapHelper()->isCanCrossAtTileCoord(nextPoint))
arr->addControlPoint(nextPoint);
// up
nextPoint = Point(tileCoord.x, tileCoord.y - 1);
if (_layer->getMapHelper()->isCanCrossAtTileCoord(nextPoint))
arr->addControlPoint(nextPoint);
// left
nextPoint = Point(tileCoord.x - 1, tileCoord.y);
if (_layer->getMapHelper()->isCanCrossAtTileCoord(nextPoint))
arr->addControlPoint(nextPoint);
// down
nextPoint = Point(tileCoord.x, tileCoord.y + 1);
if (_layer->getMapHelper()->isCanCrossAtTileCoord(nextPoint))
arr->addControlPoint(nextPoint);
return arr;
}
示例3: addChild
bool LayerAnimationStudy10::init()
{
if (!LayerColor::initWithColor(Color4B::WHITE))
{
return false;
}
Size winSize = Director::getInstance()->getWinSize();
Sprite* pItemSprite = Sprite::create("res/ui/coin.png");
pItemSprite->setPosition(100.0f,300.0f);
addChild(pItemSprite);
PointArray* pPtArray = PointArray::create(10);
pPtArray->addControlPoint(Vec2(winSize.width*0.5f, 50));
pPtArray->addControlPoint(Vec2(winSize.width-80.0f,120));
pPtArray->addControlPoint(Vec2(winSize.width-80,winSize.height-80));
pPtArray->addControlPoint(Vec2(50.0f,winSize.height-80));
pPtArray->addControlPoint(Vec2(50.0f, 120));
pPtArray->addControlPoint(Vec2(winSize.width*0.5f, 50));
int referenceCount = (int)pPtArray->getControlPoints()->size(); // 6个
for (int i=0; i<referenceCount; ++i)
{
Vec2 ptItem = pPtArray->getControlPointAtIndex(i);
createControlPoint(ptItem);
}
pItemSprite->setPosition(pPtArray->getControlPointAtIndex(0));
DrawNode* pDrawNode = DrawNode::create();
addChild(pDrawNode);
pDrawNode->drawCatmullRom(pPtArray, 100, Color4F::GREEN);
pDrawNode->setVisible(false);
TargetedAction* pTargetAction = TargetedAction::create(pItemSprite, CatmullRomTo::create(3.0f, pPtArray));
this->runAction(Sequence::create(DelayTime::create(1.0f), pTargetAction, nullptr));
return true;
}
示例4: p
PointArray *HelloWorld::walkableAdjacentTilesCoordForTileCoord(const Point &tileCoord) const
{
PointArray *tmp = PointArray::create(8);
bool t = false;
bool l = false;
bool b = false;
bool r = false;
// 上
Point p(tileCoord.x, tileCoord.y - 1);
if (this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
t = true;
}
// 左
p.setPoint(tileCoord.x - 1, tileCoord.y);
if (this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
l = true;
}
// 下
p.setPoint(tileCoord.x, tileCoord.y + 1);
if (this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
b = true;
}
// 右
p.setPoint(tileCoord.x + 1, tileCoord.y);
if (this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
r = true;
}
// 左上
p.setPoint(tileCoord.x - 1, tileCoord.y - 1);
if (t && l && this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
}
// 左下
p.setPoint(tileCoord.x - 1, tileCoord.y + 1);
if (b && l && this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
}
// 右上
p.setPoint(tileCoord.x + 1, tileCoord.y - 1);
if (t && r && this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
}
// 右下
p.setPoint(tileCoord.x + 1, tileCoord.y + 1);
if (b && r && this->isValidTileCoord(p) && !this->isWallAtTileCoord(p))
{
tmp->addControlPoint(p);
}
return tmp;
}
示例5: route
// produce a list of cordinates for the running route of an animal
void BattleField::route(Prey* prey)
{
std::list<Vec2> cordinates;
auto runningAreaY1 = _origin.y + UI_AREA_HEIGHT;
auto runningAreaY2 = DESIGN_RESOLUTION_HEIGHT - FOREST_AREA_HEIGHT;
auto runningAreaX1 = _origin.x - prey->getContentSize().width/2;
auto runningAreaX2 = _origin.x + _visibleSize.width + prey->getContentSize().width / 2;
auto appearLength = unsigned int(runningAreaY2 - runningAreaY1);
auto random = rand() % (appearLength * 2);
float startY;
auto distance = 0;
if (random < appearLength)
{
startY = random + runningAreaY1;
prey->initWithData(runningAreaX1, startY, 1);
auto cordinate = Vec2(runningAreaX1, startY);
cordinates.push_back(cordinate);
do
{
auto randomX = rand() % int(_visibleSize.width / 8) + _visibleSize.width / 5;
cordinate.x += randomX;
auto randomY = rand() % int(randomX/1.5) - randomX / 3;
cordinate.y += randomY;
if (cordinate.y < runningAreaY1)
{
cordinate.y = runningAreaY1;
}
if (cordinate.y > runningAreaY2 )
{
cordinate.y = runningAreaY2;
cordinates.push_back(cordinate);
distance = distance + sqrt(randomY*randomY + randomX*randomX);
break;
}
cordinates.push_back(cordinate);
distance = distance + sqrt(randomY*randomY + randomX*randomX);
} while (cordinate.x <= runningAreaX2&&cordinate.x >= runningAreaX1&& cordinate.y <= runningAreaY2&& cordinate.y >= runningAreaY1);
}
else
{
startY = random - appearLength + runningAreaY1;
prey->initWithData(runningAreaX2, startY, 1);
prey->setFlippedX(true);
auto cordinate = Vec2(runningAreaX2, startY);
cordinates.push_back(cordinate);
do
{
auto randomX = rand() % int(_visibleSize.width / 8) + _visibleSize.width / 5;
cordinate.x -= randomX;
auto randomY = rand() % int(randomX/1.5) - randomX / 3;
cordinate.y += randomY;
if (cordinate.y < runningAreaY1)
{
cordinate.y = runningAreaY1;
}
else if (cordinate.y > runningAreaY2)
{
cordinate.y = runningAreaY2;
cordinates.push_back(cordinate);
distance = distance + sqrt(randomY*randomY + randomX*randomX);
break;
}
cordinates.push_back(cordinate);
distance = distance + sqrt(randomY*randomY + randomX*randomX);
} while (cordinate.x <= runningAreaX2&&cordinate.x >= runningAreaX1&& cordinate.y <= runningAreaY2&& cordinate.y >= runningAreaY1);
}
PointArray* controlPoints = PointArray::create(cordinates.size());
for (auto itor = cordinates.begin(); itor != cordinates.end(); itor++)
{
controlPoints->addControlPoint(*itor);
}
prey->run();
ActionInterval* bosslineTo = CardinalSplineTo::create(distance / prey->getMovingSpeed(), controlPoints, 0);
ActionInterval* fadeout = FadeOut::create(1.5f);
Action* action = Sequence::create(bosslineTo, fadeout,NULL);
prey->runAction(action);
}