本文整理汇总了C++中CCArray::objectAtIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ CCArray::objectAtIndex方法的具体用法?C++ CCArray::objectAtIndex怎么用?C++ CCArray::objectAtIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCArray
的用法示例。
在下文中一共展示了CCArray::objectAtIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fb_Callback_Login
void GameUI_MainTitle::fb_Callback_Login(bool ret)
{
if(ret == true)
{
CCArray* friList = Facebook_Manager::sharedInstance()->getFriendList();
for(int i=0; i<friList->count(); ++i)
{
Facebook_Account* fri = (Facebook_Account*)friList->objectAtIndex(i);
Facebook_Manager::sharedInstance()->GetPicture(fri->fbID, this);
}
}
else
{
}
}
示例2: makeAFocusOfListForMotion
void MainScene::makeAFocusOfListForMotion()
{
CCArray* items = motionlist->getItems();
for (int i = 0; i < items->count(); i++) {
Layout * bg = (Layout*)items->objectAtIndex(i);
if (i == xSkill->getCurAtkIndex()) {
bg->setBackGroundColorType(LAYOUT_COLOR_SOLID);
bg->setBackGroundColor(ccBLACK);
}
else
{
bg->setBackGroundColorType(LAYOUT_COLOR_NONE);
}
}
}
示例3: disposeNodes
void Map::disposeNodes()
{
int n = nodes->count();
int m;
for (int i = 0; i < n; i ++)
{
CCArray* colList = (CCArray*) nodes->objectAtIndex(i);
m = colList->count();
for (int j = 0; j < n; j++)
{
delete colList->objectAtIndex(j);
}
delete colList;
}
delete nodes;
}
示例4: getChildren
//------------------------------------------------------------------------------
CCArray* LHLayer::allLayers(void){
#if COCOS2D_VERSION >= 0x00020000
CCArray* array = CCArray::create();
#else
CCArray* array = CCArray::array();
#endif
CCArray* children = getChildren();
for(int i = 0; i < children->count(); ++i){
CCNode* node = (CCNode*)children->objectAtIndex(i);
if(LHLayer::isLHLayer(node)){
array->addObject(node);
}
}
return array;
}
示例5: reorderZindex
void reorderZindex()
{
GraphicLayer* layer = GraphicLayer::sharedLayer();
CCArray* children = layer->getChildren();
if(children != NULL)
{
for(int i = 0 ; i < children->count(); i++)
{
RawObject* child = (RawObject*)children->objectAtIndex(i);
if(child->getZOrder() != 0)
{
layer->reorderChild(child, child->getZOrder());
}
}
}
}
示例6: if
//------------------------------------------------------------------------------
LHBezier* LHLayer::bezierWithUniqueName(const std::string& name){
CCArray* children = getChildren();
for(int i = 0; i < children->count(); ++i){
CCNode* node = (CCNode*)children->objectAtIndex(i);
if(LHBezier::isLHBezier(node)){
if(((LHBezier*)node)->getUniqueName() == name)
return (LHBezier*)node;
}
else if(LHLayer::isLHLayer(node)){
LHBezier* child = ((LHLayer*)node)->bezierWithUniqueName(name);
if(child)
return child;
}
}
return NULL;
}
示例7: initStars
//初始化矩阵数据
void RootEngine::initStars()
{
dataSource = CCArray::create();
blocksInSameColor = CCArray::create();
checkedBlocks = CCArray::create();
allNodes = CCArray::create();
allNodes->retain();
dataSource->retain();
blocksInSameColor->retain();
checkedBlocks->retain();
Size contentSize = containerView->getContentSize();
perWidth = contentSize.width/lineCount;
perHeight = perWidth;
CCArray* nameArray = CCArray::create();
for (int i = 0; i<typeCount; i++) {
__String* s = __String::createWithFormat("img_star_%02d.png",i);
nameArray->addObject(s);
}
for (int i = 0; i<lineCount; i++) {
CCArray* lineArray = CCArray::create();
dataSource->addObject(lineArray);
for (int j = 0; j<rowCount; j++) {
int type = arc4random()%typeCount;
StarModel* model = new StarModel();
model->type = type;
model->line = i;
model->row = j;
lineArray->addObject(model);
__String* file = (__String*)nameArray->objectAtIndex(model->type);
Sprite* bSprite = Sprite::create(file->getCString());
bSprite->setPosition(Point((i+ 0.5)*this->perHeight, (j+0.5)*this->perWidth));
bSprite->setScale(CommonUtil::getScaleForTargetWithImage(perWidth, bSprite));
containerView->addChild(bSprite);
StarNode* node = new StarNode();
node->sprite = bSprite;
node->model = model;
node->targetCenter = bSprite->getPosition();
model->node = node;
allNodes->addObject(node);
}
}
}
示例8: checkDeleteBubbles
void GameBoard::checkDeleteBubbles(Bubble * bubble){
CCArray * neighbors = getNeighbors(bubble);
neighbors->retain();
Bubble * tempBubble;
bool hasChecked = false;
CCPoint *point;
CCPoint *checkedPoint;
for(int i = 0; i < neighbors->count(); i++){
point = (CCPoint *) neighbors->objectAtIndex(i);
//CCLOG("P:%i", (int) point->y);
//CCLOG("PP:%i", (int) point->x);
tempBubble = getBubble(point->y, point->x);
if (tempBubble == NULL) {
continue;
}
tempBubble->retain();
for (int j = 0; j < bubblesChecked->count(); j++) {
checkedPoint = (CCPoint *) bubblesChecked->objectAtIndex(j);
// CCLOG("XX:%i", (int) checkedPoint->x);
// CCLOG("YX:%i", (int) checkedPoint->y);
// CCLOG("XXX:%i", (int) tempBubble->col);
// CCLOG("YXX:%i", (int) tempBubble->row);
if (checkedPoint->x == tempBubble->col && checkedPoint->y == tempBubble->row) {
hasChecked = true;
break;
}
}
if (hasChecked) {
hasChecked = false;
continue;
}else{
bubblesChecked->addObject(point);
}
// CCLOG("ID:%i", (int) tempBubble->bubbleID);
// CCLOG("X:%i", (int) point->x);
// CCLOG("Y:%i", (int) point->y);
if(bubble->bubbleID == tempBubble->bubbleID){
bubblesDeleted->addObject(point);
checkDeleteBubbles(tempBubble);
}
}
return ;
}
示例9: GetActionByName
UIAction* UIActionManager::GetActionByName(const char* jsonName,const char* actionName)
{
CCArray* actionList = (CCArray*)(m_pActionDic->objectForKey(jsonName));
if (!actionList)
{
return NULL;
}
for (int i=0; i<actionList->count(); i++)
{
UIAction* action = dynamic_cast<UIAction*>(actionList->objectAtIndex(i));
if (strcmp(actionName, action->getName()) == 0)
{
return action;
}
}
return NULL;
}
示例10: getButtonAtPosition
Image* Scene::getButtonAtPosition(Vec2 position, bool state)
{
Image* target = NULL;
CCArray* objects = GraphicLayer::sharedLayer()->allVisibleObjectsAtPosition(position);
for(int i = 0; i < objects->count() && target == NULL; i++)
{
RawObject* obj = (RawObject*)objects->objectAtIndex(i);
if(obj->isVisible() && obj->getEventActivated() && !obj->getEventName().empty() && obj->getEventName()[0] != '\0' && dynamic_cast<Image*>(obj) != NULL)
{
//If state = false, the object imagefile must finish by "-on" and and have an _OriginalImageFile
char *end = strrchr(((Image*)obj)->getImageFile().c_str(), '-');
if(state || (end && strcmp(end, "-on") == 0 && obj->getEventInfos()->objectForKey("_OriginalImageFile") != NULL))
target = (Image*)obj;
}
}
return target;
}
示例11: update
void TestColliderDetector::update(float delta)
{
armature2->setVisible(true);
CCRect rect = bullet->boundingBox();
// This code is just telling how to get the vertex.
// For a more accurate collider detection, you need to implemente yourself.
CCDictElement *element = NULL;
CCDictionary *dict = armature2->getBoneDic();
CCDICT_FOREACH(dict, element)
{
CCBone *bone = static_cast<CCBone*>(element->getObject());
CCArray *bodyList = bone->getColliderBodyList();
CCObject *object = NULL;
CCARRAY_FOREACH(bodyList, object)
{
ColliderBody *body = static_cast<ColliderBody*>(object);
CCArray *vertexList = body->getCalculatedVertexList();
float minx, miny, maxx, maxy = 0;
int length = vertexList->count();
for (int i = 0; i<length; i++)
{
CCContourVertex2 *vertex = static_cast<CCContourVertex2*>(vertexList->objectAtIndex(i));
if (i == 0)
{
minx = maxx = vertex->x;
miny = maxy = vertex->y;
}
else
{
minx = vertex->x < minx ? vertex->x : minx;
miny = vertex->y < miny ? vertex->y : miny;
maxx = vertex->x > maxx ? vertex->x : maxx;
maxy = vertex->y > maxy ? vertex->y : maxy;
}
}
CCRect temp = CCRectMake(minx, miny, maxx - minx, maxy - miny);
if (temp.intersectsRect(rect))
{
armature2->setVisible(false);
}
}
示例12: executeNodeEvent
int CCLuaEngine::executeNodeEvent(CCNode* pNode, int nAction)
{
CCLuaValueDict event;
switch (nAction)
{
case kCCNodeOnEnter:
event["name"] = CCLuaValue::stringValue("enter");
break;
case kCCNodeOnExit:
event["name"] = CCLuaValue::stringValue("exit");
break;
case kCCNodeOnEnterTransitionDidFinish:
event["name"] = CCLuaValue::stringValue("enterTransitionFinish");
break;
case kCCNodeOnExitTransitionDidStart:
event["name"] = CCLuaValue::stringValue("exitTransitionStart");
break;
case kCCNodeOnCleanup:
event["name"] = CCLuaValue::stringValue("cleanup");
break;
default:
return 0;
}
m_stack->clean();
m_stack->pushCCLuaValueDict(event);
CCArray *listeners = pNode->getAllScriptEventListeners();
CCScriptHandlePair *p;
for (int i = listeners->count() - 1; i >= 0; --i)
{
p = dynamic_cast<CCScriptHandlePair*>(listeners->objectAtIndex(i));
if (p->event != NODE_EVENT || p->removed) continue;
m_stack->copyValue(1);
m_stack->executeFunctionByHandler(p->listener, 1);
m_stack->settop(1);
}
m_stack->clean();
return 0;
}
示例13: ccTouchesMoved
void XTLayer::ccTouchesMoved(cocos2d::CCSet* _touches, cocos2d::CCEvent* event)
{
this->_touchHasMoved = true;
CCArray *allTouches = xtAllTouchextromSet(_touches);
CCTouch* fingerOne = (CCTouch *)allTouches->objectAtIndex(0);
CCPoint pointOne = CCDirector::sharedDirector()->convertToUI(fingerOne->getLocationInView());
CCPoint location = this->convertToNodeSpace(pointOne);
this->xtActualPoint = location;
CCLog("Position:%f,%f",location.x,location.y);
// Passthrough
this->xtTouchesMoved(location);
this->xtTouchesMoved(_touches, event);
}
示例14: keyboardWillShow
/**
* 键盘将要出现的时候
*/
void LoginView::keyboardWillShow(CCIMEKeyboardNotificationInfo& info)
{
CCLog("LoginView:keyboardWillShowAt(origin:%f,%f, size:%f,%f)",
info.end.origin.x, info.end.origin.y, info.end.size.width, info.end.size.height);
if (! this->mTrackNodeArray)
{
return;
}
CCNode* trackNode = NULL ;
CCRect rectTracked ;
for(int i=0; i<this->mTrackNodeArray->count(); i++)
{
trackNode = (CCNode*) this->mTrackNodeArray->objectAtIndex(i) ;
rectTracked = getRect(trackNode);
CCLog("LoginView:trackingNodeAt(origin:%f,%f, size:%f,%f)",
rectTracked.origin.x, rectTracked.origin.y, rectTracked.size.width, rectTracked.size.height);
// if the keyboard area doesn't intersect with the tracking node area, nothing need to do.
if (! CCRect::CCRectIntersectsRect(rectTracked, info.end))
{
continue ;
}
// assume keyboard at the bottom of screen, calculate the vertical adjustment.
float adjustVert = info.end.getMaxY() - rectTracked.getMinY();
CCLog("LoginView:needAdjustVerticalPosition(%f)", adjustVert);
// move all the children node of KeyboardNotificationLayer
CCArray* children = getChildren();
CCNode* node = 0;
int count = children->count();
CCPoint pos;
for (int i = 0; i < count; ++i)
{
node = (CCNode*)children->objectAtIndex(i);
pos = node->getPosition();
pos.y += adjustVert;
node->setPosition(pos);
}
}
}
示例15: tick
void HelloWorld::tick(float dt) {
//=================================
CCPoint backgroundScrollVert = ccp(-2000, 0);
pBackgroundNode->setPosition(ccpAdd(pBackgroundNode->getPosition(), ccpMult(backgroundScrollVert, dt)));
CCArray *BackGrounds = CCArray::createWithCapacity(2);
BackGrounds->addObject(pSprite);
BackGrounds->addObject(pNextSprite);
for ( int ii = 0; ii < BackGrounds->count(); ii++ ) {
CCSprite * BackGround = (CCSprite *)(BackGrounds->objectAtIndex(ii));
float xPosition = pBackgroundNode->convertToWorldSpace(BackGround->getPosition()).x;
float size = BackGround->getContentSize().width;
if ( xPosition < -size/2 ) {
pBackgroundNode->incrementOffset(ccp(BackGround->getContentSize().width*2,0),BackGround);
}
}
//===================================
pworld->Step(dt, 10, 10);
for(b2Body *b = pworld->GetBodyList(); b; b=b->GetNext()) {
if (b->GetUserData() != NULL) {
if(b->GetType() == b2_dynamicBody)
{
CCSprite *ballData = (CCSprite *)b->GetUserData();
ballData->setPosition(ccp(b->GetPosition().x * PTM_RATIO,
b->GetPosition().y * PTM_RATIO));
ballData->setRotation (-1 * CC_RADIANS_TO_DEGREES(b->GetAngle()));
}
/*else if(b->GetType() == b2_staticBody)
{
CCSprite *ballData = (CCSprite *)b->GetUserData();
ballData->setPosition(ccp(b->GetPosition().x * PTM_RATIO,
b->GetPosition().y * PTM_RATIO));
ballData->setRotation (-1 * CC_RADIANS_TO_DEGREES(b->GetAngle()));
}*/
}
}
}