本文整理汇总了C++中CCPointArray::getControlPointAtIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ CCPointArray::getControlPointAtIndex方法的具体用法?C++ CCPointArray::getControlPointAtIndex怎么用?C++ CCPointArray::getControlPointAtIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCPointArray
的用法示例。
在下文中一共展示了CCPointArray::getControlPointAtIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showLiziXiaoguo
void MainFooterLayer::showLiziXiaoguo(CCNode* pParent, int iTag)
{
//极限守城20级开启,所以效果20级才显示
//竞技8级开启,所以效果8级才显示
int iMinLevel = 8;
if (iTag == TAG_Jixianshoucheng_lizi_Ani)
{
iMinLevel = 20;
}
if (!pParent || MyselfManager::getManager()->getMyZhuJueData()->getCurrentProperty().level < iMinLevel)
{
return;
}
CCNode* pNode = pParent->getChildByTag(iTag);
if (pNode)
{
return;
}
CCParticleSystemQuad* par = CCParticleSystemQuad::create("jingji_xiaoguo.plist");
pParent->addChild(par, 2, iTag);
//par->setScale(0.5f);
//par->setSpeed(10);
par->setPosition(ccp(0, 0));
CCPointArray *array = CCPointArray::create(20);
array->addControlPoint(ccp(0, 0));
array->addControlPoint(ccp(pParent->getContentSize().width, 0));
array->addControlPoint(ccp(pParent->getContentSize().width, pParent->getContentSize().height));
array->addControlPoint(ccp(0, pParent->getContentSize().height));
float dt = 0.5f;
CCMoveTo* action1 = CCMoveTo::create(dt, array->getControlPointAtIndex(1));
CCMoveTo* action2 = CCMoveTo::create(dt, array->getControlPointAtIndex(2));
CCMoveTo* action3 = CCMoveTo::create(dt, array->getControlPointAtIndex(3));
CCMoveTo* action4 = CCMoveTo::create(dt, array->getControlPointAtIndex(0));
CCSequence* quece = CCSequence::create(action1, action2, action3, action4, NULL);
par->runAction(
CCRepeatForever::create(
//FXCircleBy::create(1.0f, ccp(pJingjiItem->getContentSize().width/2, pJingjiItem->getContentSize().height/2 + 5), 24, 360)
quece
)
);
}
示例2: reverse
CCActionInterval* CCCardinalSplineBy::reverse()
{
CCPointArray *copyConfig = (CCPointArray*)m_pPoints->copy();
//
// convert "absolutes" to "diffs"
//
CCPoint p = copyConfig->getControlPointAtIndex(0);
for (unsigned int i = 1; i < copyConfig->count(); ++i)
{
CCPoint current = copyConfig->getControlPointAtIndex(i);
CCPoint diff = ccpSub(current, p);
copyConfig->replaceControlPoint(diff, i);
p = current;
}
// convert to "diffs" to "reverse absolute"
CCPointArray *pReverse = copyConfig->reverse();
copyConfig->release();
// 1st element (which should be 0,0) should be here too
p = pReverse->getControlPointAtIndex(pReverse->count()-1);
pReverse->removeControlPointAtIndex(pReverse->count()-1);
p = ccpNeg(p);
pReverse->insertControlPoint(p, 0);
for (unsigned int i = 1; i < pReverse->count(); ++i)
{
CCPoint current = pReverse->getControlPointAtIndex(i);
current = ccpNeg(current);
CCPoint abs = ccpAdd(current, p);
pReverse->replaceControlPoint(abs, i);
p = abs;
}
return CCCardinalSplineBy::create(m_fDuration, pReverse, m_fTension);
}
示例3: setPosType
void CEnemySprite::setPosType(int posType)
{
CCSize screen = CCDirector::sharedDirector()->getWinSize();
CCSize enemySize = m_pSprite->getContentSize();
CCPointArray* startPosArray = CCPointArray::create(EnemyStartTypeMax);
startPosArray->addControlPoint(ccp(0, 0));//EnemyStartTypeNone
startPosArray->addControlPoint(ccp(screen.width / 2, screen.height + enemySize.height / 2));//1 EnemyStartTypeTop
startPosArray->addControlPoint(ccp(screen.width / 3, screen.height + enemySize.height / 2));//2 EnemyStartTypeTopLeft
startPosArray->addControlPoint(ccp(screen.width * 2 / 3, screen.height + enemySize.height / 2));//3 EnemyStartTypeTopRight
startPosArray->addControlPoint(ccp(-enemySize.width / 2, screen.height * 2 / 3));//4 EnemyStartTypeLeft
startPosArray->addControlPoint(ccp(screen.width + enemySize.width / 2, screen.height * 2 / 3));//5 EnemyStartTypeRight
startPosArray->addControlPoint(ccp(-enemySize.width / 2, screen.height / 3));//6 EnemyStartTypeLeft2
startPosArray->addControlPoint(ccp(screen.width + enemySize.width / 2, screen.height / 3));//7 EnemyStartTypeRight2
m_pos = startPosArray->getControlPointAtIndex(posType);
CCLog("CEnemySprite::setPosType posType: %d, pos: %0.2f, %0.2f", posType, m_pos.x, m_pos.y);
m_pSprite->setPosition(m_pos);
}
示例4: showStarsFadeEffect
void IOSStoreLayer::showStarsFadeEffect(CCNode* pBox)
{
int iStarCount = 8;
CCPointArray* pPointArray = randStarPoint(iStarCount);
for (int i = 0; i < iStarCount; ++i)
{
CCSprite* pStar = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"daoju_baoxiang_xiaoguo_2.png").c_str());
pStar->setScale(this->randScale());
pStar->setRotation(this->randRotation());
pBox->addChild(pStar);
CCPoint point = pPointArray->getControlPointAtIndex(i);
pStar->setPosition(ccp(point.x , point.y));
pStar->setTag(box_star_tag);
float dt = CCRANDOM_0_1() + 1.0f;
float scale = CCRANDOM_0_1() + 0.5f;
pStar->runAction(CCRepeatForever::create(CCSequence::create(CCFadeOut::create(dt), CCFadeIn::create(dt), NULL)));
CCScaleBy* pscaleby = CCScaleBy::create(dt, scale);
pStar->runAction(CCRepeatForever::create(CCSequence::create(pscaleby, pscaleby->reverse(), NULL)));
}
}
示例5: init
bool AllianceAreaPopupView::init(){
if(!PopupBaseView::init()){
return false;
}
setIsHDPanel(true);
isMoving = false;
this->setModelLayerOpacity(0);
this->setContentSize(CCDirector::sharedDirector()->getWinSize());
m_picNode = CCNode::create();
m_picNode->setContentSize(CCSize(_tile_width * 2, _tile_height * 2));
m_picNode->setAnchorPoint(ccp(0, 0));
CCPoint testPoint =PopupViewController::getInstance()->getTouchPoint() + ccp(-_tile_width, -_tile_height);
// m_picNode->setPosition(PopupViewController::getInstance()->getTouchPoint() + ccp(-_tile_width, -_tile_height));
CCPoint tilePoint = WorldController::getInstance()->getPointByIndex(m_tileIndex);
CCPoint viewPoint = getInLayerPoint(tilePoint);
viewPoint = viewPoint + ccp(-_tile_width * 1.5, -_tile_height);
m_picNode->setPosition(viewPoint);
m_cityNode = CCNode::create();
/*int mapIndex = 3;
while (mapIndex >= 0) {
auto arr = WorldController::getInstance()->getCityPicArr(mapIndex, 0, false ,44996);
int posX = _tile_width / 2;
int posY = _tile_height / 2;
if(mapIndex == 0 || mapIndex == 2){
posX = _tile_width;
}
if(mapIndex == 3){
posX = _tile_width + posX;
}
if(mapIndex == 1 || mapIndex == 3){
posY = _tile_height;
}
if(mapIndex == 2){
posY = _tile_height + posY;
}
auto itMap = arr.begin();
while (itMap!=arr.end()) {
std::string picName = (*itMap).pic;
int addX = (*itMap).x;
int addY = (*itMap).y;
auto sprite = CCLoadSprite::createSprite(picName.c_str());
sprite->setAnchorPoint(ccp(0, 0));
if (CCCommonUtils::isIosAndroidPad()) {
m_cityNode->addChild(sprite);
sprite->setPosition(ccp(posX, posY) - ccp(_tile_width / 2, _tile_height / 2) + ccp(addX, addY));
}
else {
m_picNode->addChild(sprite);
sprite->setPosition(ccp(posX, posY) - ccp(_tile_width / 2, _tile_height / 2) + ccp(addX, addY));
}
++itMap;
}
mapIndex--;
}*/
auto tower = CCLoadSprite::createSprite("territory_fort.png");
tower->setPosition(ccp(_tile_width -25, _tile_height + 62));
m_picNode->addChild(tower);
if (CCCommonUtils::isIosAndroidPad()) {
m_picNode->addChild(m_cityNode);
m_cityNode->setScale(WORLD_DEFAULT_HD_SCALE);
m_cityNode->setPosition(ccp(-_tile_width * (WORLD_DEFAULT_HD_SCALE - 1),-_tile_height * (WORLD_DEFAULT_HD_SCALE - 1)));
}
CCPointArray* pointArr = CCPointArray::create(3);
pointArr->addControlPoint(ccp(-70,59));
pointArr->addControlPoint(ccp(-2,23));
pointArr->addControlPoint(ccp(66,57));
CCLoadSprite::doResourceByCommonIndex(507, true);
for (int i = 0; i < 3; i++) {
auto bannerSprite = CCFlagWaveSprite::create(CCLoadSprite::loadResource("1212_double.png"));
if (CCCommonUtils::isIosAndroidPad()) {
bannerSprite->setScale(0.25);
}
else
bannerSprite->setScale(0.18);
bannerSprite->setPosition(ccp(_tile_width, _tile_height)+pointArr->getControlPointAtIndex(i) + ccp(12, 20));
m_picNode->addChild(bannerSprite);
}
CCLoadSprite::doResourceByCommonIndex(507, false);
if (CCCommonUtils::isIosAndroidPad()) {
m_cancelBtn = CCControlButton::create(CCLoadSprite::createScale9Sprite("but_blue.png"));
m_cancelBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(AllianceAreaPopupView::onCancelBtnClick), CCControlEventTouchUpInside);
m_cancelBtn->setPreferredSize(CCSize(160, 70));
m_cancelBtn->setScaleX(2.1);
m_cancelBtn->setScaleY(1.7);
m_confirmBtn = CCControlButton::create(CCLoadSprite::createScale9Sprite("btn_green3.png"));
m_confirmBtn->setBackgroundSpriteForState(CCLoadSprite::createScale9Sprite("btn_green3.png"),CCControlStateHighlighted);
m_confirmBtn->setBackgroundSpriteForState(CCLoadSprite::createScale9Sprite("Btn_grey.png"),CCControlStateDisabled);
m_confirmBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(AllianceAreaPopupView::onConfirmBtnClick), CCControlEventTouchUpInside);
m_confirmBtn->setPreferredSize(CCSize(160, 70));
m_confirmBtn->setScaleX(2.1);
m_confirmBtn->setScaleY(1.7);
//.........这里部分代码省略.........
示例6: setTileEffect
// Breakable(破壊可能)のタイルを赤にする
void Game::setTileEffect(CCPoint position)
{
// stage and area
_hud->setStageLabel(1, 1);
_hud->setLifeLabel(1);
CCPoint tileCoord = this->tileCoordForPosition(position);
// キャラクターの上下左右の座標
CCPointArray *pointArray = CCPointArray::create(4);
pointArray->addControlPoint(ccp(0,1));
pointArray->addControlPoint(ccp(-1,0));
pointArray->addControlPoint(ccp(1,0));
pointArray->addControlPoint(ccp(0,-1));
for(int i = 0; i < pointArray->count(); i++){
CCPoint point = pointArray->getControlPointAtIndex(i);
//CCLog("(%f,%f)", point.x, point.y);
CCPoint tmpTileCoord = ccp(tileCoord.x + point.x, tileCoord.y + point.y);
if(tmpTileCoord.x < 0 || tmpTileCoord.x > _tileMap->getMapSize().width -1 ||
tmpTileCoord.y < 0 || tmpTileCoord.y > _tileMap->getMapSize().height - 1)
{
continue;
}
//CCLog("(%f,%f)", tmpTileCoord.x, tmpTileCoord.y);
//CCLog("TileX %f, TileY %f", _tileMap->getMapSize().width, _tileMap->getMapSize().height);
int tileGid = _meta->tileGIDAt(tmpTileCoord);
if (tileGid) {
CCDictionary *properties = _tileMap->propertiesForGID(tileGid);
if (properties) {
// obstacle
CCString *collision = new CCString();
// Breakableを赤
*collision = *properties->valueForKey("Breakable");
if (collision && (collision->compare("True") == 0)) {
CCSprite *sprite = _background->tileAt(tmpTileCoord);
//sprite->setTag(TAPPABLE);
// red
sprite->setColor(ccRED);
}
}
}
}
// 白に戻す
// まず詰める
/*
◯は赤なので変化させない
|6,0|6,1|6,2|6,3|6,4|6,5|6,6|
|5,0|5,1|5,2|5,3|5,4|5,5|5,6|
|4,0|4,1|4,2|◯4,3|4,4|4,5|4,6|
|3,0|3,1|◯3,2|3,3|◯3,4|3,5|3,6|
|2,0|2,1|2,2|◯2,3|2,4|2,5|2,6|
|1,0|1,1|1,2|1,3|1,4|1,5|1,6|
|0,0|0,1|0,2|0,3|0,4|0,5|0,6|
*/
CCPointArray *revertPointArray = CCPointArray::create(255);
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) {
if((i == 3 && j == 2) || (i == 3 && j == 4) ||
(i == 2 && j == 3) || (i == 4 && j == 3)
)
{
continue;
}
revertPointArray->addControlPoint(ccp(-3 + j, -3 + i));
}
}
// 詰めたものから適用
for(int i = 0; i < revertPointArray->count(); i++) {
CCPoint point = revertPointArray->getControlPointAtIndex(i);
//CCLog("(%f,%f)", point.x, point.y);
CCPoint tmpTileCoord = ccp(tileCoord.x + point.x, tileCoord.y + point.y);
// 画面端はエラーになるので適用させない
if(tmpTileCoord.x < 0 || tmpTileCoord.x > _tileMap->getMapSize().width - 1||
tmpTileCoord.y < 0 || tmpTileCoord.y > _tileMap->getMapSize().height - 1)
{
continue;
}
//CCLog("(%f,%f)", tmpTileCoord.x, tmpTileCoord.y);
int tileGid = _meta->tileGIDAt(tmpTileCoord);
if (tileGid) {
CCDictionary *properties = _tileMap->propertiesForGID(tileGid);
if (properties) {
// obstacle
CCString *collision = new CCString();
// Breakableのみ戻す
*collision = *properties->valueForKey("Breakable");
//.........这里部分代码省略.........