本文整理汇总了C++中CCLayer::getPositionX方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayer::getPositionX方法的具体用法?C++ CCLayer::getPositionX怎么用?C++ CCLayer::getPositionX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLayer
的用法示例。
在下文中一共展示了CCLayer::getPositionX方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ccTouchMoved
void GiftListView::ccTouchMoved( CCTouch *pTouch, CCEvent *pEvent )
{
CCPoint touchPoint=pTouch->getLocation();
float nMovex = touchPoint.x - mMoveBeginPoint.x;
//CCLOG("movex:%f",nMovex);
mMovex += nMovex;
if (!(nMovex<5 && nMovex>-5))//移动
{
if (mNowSeledItem && mNowSeledItem->mStatus != GiftItem::nor)
{
mNowSeledItem->setStatus(GiftItem::nor);
mNowSeledItem = NULL;
}
}
CCLayer* firstPage = (CCLayer*)mPages.objectAtIndex(0);
CCLayer* lastPage = (CCLayer*)mPages.objectAtIndex(mPages.count()-1);
int f=0;//阻力
if (firstPage->getPositionX()>0 || lastPage->getPositionX()<0)//超出边界有阻力
{
f = nMovex/2;
}
for (int i=0;i<(int)mPages.count();i++)
{
CCLayer* page = (CCLayer*)mPages.objectAtIndex(i);
CCPoint curPoint = page->getPosition();
CCPoint nextPoint = ccp(curPoint.x+nMovex-f,curPoint.y);
page->setPosition(nextPoint);
}
mMoveBeginPoint.setPoint(touchPoint.x,touchPoint.y);
}
示例2: ccTouchEnded
void GiftListView::ccTouchEnded( CCTouch *pTouch, CCEvent *pEvent )
{
this->unschedule(schedule_selector(GiftListView::touchUpdate));
//CCLOG("touch end-------");
if (mNowSeledItem)
{
if (!mIsClickEnable)
return;
mNowSeledItem->setStatus(GiftItem::nor);
if (mApater !=NULL)
mApater->onSelItem(mNowSeledItem);
mNowSeledItem = NULL;
return;
}
CCLayer* minDisPage = (CCLayer*)mPages.objectAtIndex(0);
int minDis = abs(minDisPage->getPositionX());
int minx = minDisPage->getPositionX();
int minPage = 1;
int i=1;
//CCLOG("list move m:%f t:%f v:%f",mMovex,mTimer,abs(mMovex/mTimer));
if ( abs(mMovex/mTimer)>500)//滑动速度很快,翻页
{
CCLOG("move far!!!");
int dis = (mMovex<0)?1:-1;
int nextPage = (mPageCurr+dis<1)?1:(mPageCurr+dis);
if (nextPage>(int)mPages.count())
nextPage = mPages.count();
minDisPage = (CCLayer*)mPages.objectAtIndex(nextPage-1);
minx = minDisPage->getPositionX();
minPage = nextPage;
}
else//滑动速度慢 判断最后哪一页
{
for (;i<mPageTotal;i++)//获取离要到的页面
{
CCLayer* page = (CCLayer*)mPages.objectAtIndex(i);
int dis = abs(page->getPositionX());
if (dis<minDis)
{
minDisPage = page;
minDis = dis;
minx =page->getPositionX();
minPage = i+1;
}
}
}
mPageCurr = minPage;
setPageMarkerShow(mPageCurr);
//CCLOG("minPage %d",minPage);
int moveDis = -minx;
for (i=0;i<mPageTotal;i++)
{
CCLayer* page = (CCLayer*)mPages.objectAtIndex(i);
CCPoint topoint = ccp(moveDis,page->getPositionY());
CCActionInterval* moveto = CCMoveBy::create(0.6f,topoint);
CCEaseExponentialOut* moveAction = CCEaseExponentialOut::create(moveto);
moveAction->setTag(999);
page->runAction(moveAction);
}
mIsMove =false;
mMovex = 0;
mTimer = 0;
}