Exemple #1
0
bool ToTextLayer::DerSelMenu(Script* ts){
	do{
		CC_BREAK_IF(!ts);
		//CCDictionary* attrs = ts->attributes;
		CCArray* scrs = ts->scriptnodes;
		int n = ts->m_snum;
		int maxleng = 0;	/* <最大字长 */

		CCArray* tm = CCArray::createWithCapacity(n);
		for(int i=0;i<n;i++){
			Script* tmp = (Script*) scrs->objectAtIndex(i);		//set more here if you want more.

			float sf = 1;
			CCSprite* spriteNormal; 
			CCSprite* spriteSelected;
			CCSprite* spriteDisabled;

			spriteNormal = CCSprite::create("Images/menuitemsprite2.png", CCRectMake(0,23*2/sf,70/sf,23/sf));
			spriteSelected = CCSprite::create("Images/menuitemsprite2.png", CCRectMake(0,23*1/sf,70/sf,23/sf));
			spriteDisabled = CCSprite::create("Images/menuitemsprite2.png", CCRectMake(0,23*0,70/sf,23/sf));

			SpriteTextMenuItem* item2 = new SpriteTextMenuItem();
			item2->autorelease();
			item2->initWithNormalSprite(spriteNormal, spriteSelected, spriteDisabled,this, menu_selector(ToTextLayer::menucallback) );
			item2->settext(tmp->getstring("content"), FNT_CHN, 24);
			item2->setSData(tmp->getint("jump"));
			item2->setTag(100+i);

			maxleng = max(maxleng, strlen(tmp->getstring("content")));

			tm->insertObject(item2,i);
		}
		sel_menu = MouseMenu::createWithArray(tm);	

		sel_menu->setTouchEnabled(false);
		sel_menu->alignItemsVertically();
		sel_menu->setTag(MENUTAG);
		sel_menu->setPosition(ccp(s.width/2, s.height/2));
		sel_menu->f_setaligntype(1);
		addChild(sel_menu);

		float t_width,t_height;

		t_width = maxleng * 30;
		t_height = n * 30;

		CCScale9Sprite* nback = CCScale9Sprite::create("Images/popup_back.png"); 
		nback->setContentSize(CCSize(t_width+ 23,t_height+ 22));
		nback->setAnchorPoint(ccp(0.5,0.5));
		nback->setPosition(s.width/2, s.height/2 - t_height/2 +30 );
		nback->setOpacity(200);
		nback->setTag(MENUTAG+1);
		addChild(nback,-1);

		e_layerstate = 1;

		return true;
	}while(0);
	return false;
}
CCArray* CollisionEngine::getSurroundingTilesAtPosition(CCPoint position,
		CCTMXLayer *layer) {

	CCPoint plPos = tileCoordForPosition(position);
	CCArray *gids = CCArray::create();

	for (int i = 0; i < 9; i++) {
		int c = i % 3;
		int r = (int) (i / 3);
		CCPoint tilePos = ccp(plPos.x + (c - 1), plPos.y + (r - 1));
		// fall into a hole
		if (tilePos.y > (map->getMapSize().height - 1)) {

			// kill the enemy here

			//this->gameOver(false);
			return NULL;
		}

		int tgid = layer->tileGIDAt(tilePos);

		CCRect tileRect = tileRectFromTileCoords(tilePos);

		CCDictionary *tileDict = CCDictionary::create();

		CCXNumericData *tilePosData = CCXNumericData::create();
		CCXNumericData *tgidData = CCXNumericData::create();
		CCXNumericData *rectOrgXData = CCXNumericData::create();
		CCXNumericData *rectOrgYData = CCXNumericData::create();

		tilePosData->setPoint(tilePos);
		tgidData->setIntValue(tgid);
		rectOrgXData->setFloatValue(tileRect.origin.x);
		rectOrgYData->setFloatValue(tileRect.origin.y);
		tileDict->setObject(tgidData, "gid");
		tileDict->setObject(rectOrgXData, "x");
		tileDict->setObject(rectOrgYData, "y");
		tileDict->setObject(tilePosData, "tilePos");

		gids->addObject(tileDict);
	}

	gids->removeObjectAtIndex(4);
	gids->insertObject(gids->objectAtIndex(2), 6);
	gids->removeObjectAtIndex(2);
	gids->exchangeObjectAtIndex(4, 6);
	gids->exchangeObjectAtIndex(0, 4);

	return gids;

}
Exemple #3
0
void ActionNode::insertFrame(int index, ActionFrame* frame)
{
	if (frame == NULL)
	{
		return;
	}
	int frameType = frame->getFrameType();
	CCArray* cArray = (CCArray*)m_FrameArray->objectAtIndex(frameType);
	if (cArray == NULL)
	{
		return;
	}	
	cArray->insertObject(frame,index);
}
Exemple #4
0
void DaojuEngine::daoJuConfirmHitPoint(Point p, int type){
    int row = p.y / this->perHeight;
    int line = p.x / this->perWidth;
    StarModel* model = this->getModelForLineAndRow(line, row);
    if (!model) {
        return;
    }
    switch (type) {
        case 0:
        {
            model->type = 2;
            model->node->sprite->setTexture("image_02.png");
            break;
        }
        case 1:
        {
            CCArray* arr = CCArray::create();
            arr->addObject(model);
            destroySlectedArray(arr,NULL);
            break;
        }
        case 2:
        {
            CCArray* arr = CCArray::create();
            arr->addObject(model);
            StarModel* block = getModelForLineAndRow(model->line-1, model->row);
            if (block) {
                arr->addObject(block);
            }
            block = getModelForLineAndRow(model->line+1, model->row);
            if (block) {
                arr->addObject(block);
            }
            block = getModelForLineAndRow(model->line, model->row-1);
            if (block) {
                arr->addObject(block);
            }
            block = getModelForLineAndRow(model->line, model->row+1);
            if (block) {
                arr->addObject(block);
            }
            block = getModelForLineAndRow(model->line-1, model->row-1);
            if (block) {
                arr->addObject(block);
            }
            block = getModelForLineAndRow(model->line+1, model->row+1);
            if (block) {
                arr->addObject(block);
            }
            block = getModelForLineAndRow(model->line+1, model->row-1);
            if (block) {
                arr->addObject(block);
            }
            block = getModelForLineAndRow(model->line-1, model->row+1);
            if (block) {
                arr->addObject(block);
            }
            destroySlectedArray(arr,NULL);
            break;
        }
        case 3:
        {
            CCArray* nameArray = CCArray::create();
            for (int i = 0; i<5; i++) {
                __String* s = __String::createWithFormat("image_0%d.png",i);
                nameArray->addObject(s);
            }
            
            for (int i = 0; i<dataSource->count(); i++) {
                CCArray* lineArr = (CCArray*)dataSource->objectAtIndex(i);
                for (int j = 0; j<lineArr->count(); j++) {
                    StarModel* model = getModelForLineAndRow(i, j);
                    
                    int type = arc4random()%typeCount;
                    model->type = type;
                    model->line = i;
                    model->row = j;
                    
                    __String* file = (__String*)nameArray->objectAtIndex(model->type);
                    Sprite* bSprite = model->node->sprite;
                    bSprite->setTexture(file->getCString());
                }
            }
            
            break;
        }
        case 4:
        {
            for (int i = 0; i<dataSource->count(); i++) {
                CCArray* lineArr = (CCArray*)dataSource->objectAtIndex(i);
                for (int j = 0; j<lineArr->count(); j++) {
                    StarModel* model = getModelForLineAndRow(i, j);
                    if (!model) {
                        return;
                    }
                    int tLine = arc4random()%dataSource->count();
                    int tRow = arc4random()%(((CCArray*)dataSource->objectAtIndex(tLine))->count());
                    
                    StarModel* tModel = getModelForLineAndRow(tLine, tRow);
                    if (!tModel) {
                        return;
                    }
                    
                    CCArray* TEMP = NULL;
                    
                    if (tModel) {
                        
                        TEMP = (CCArray*)dataSource->objectAtIndex(model->line);
                        TEMP->removeObjectAtIndex(model->row);
                        TEMP->insertObject(tModel, model->row);
                        
                        TEMP = (CCArray*)dataSource->objectAtIndex(tModel->line);
                        TEMP->removeObjectAtIndex(tModel->row);
                        TEMP->insertObject(model, tModel->row);
                        
                        
                        int temp = model->line;
                        model->line = tModel->line;
                        tModel->line = temp;
                        
                        temp = model->row;
                        model->row = tModel->row;
                        tModel->row = temp;
                        
                    }
                }
            }
            
            for (int i = 0; i<dataSource->count(); i++) {
                for (int j = 0; j<((CCArray*)dataSource->objectAtIndex(i))->count(); j++) {
                    StarModel* model = (StarModel*)((CCArray*)dataSource->objectAtIndex(i))->objectAtIndex(j);
                    model->line = i;
                    model->row = j;
                    StarNode* node = model->node;
                    Point p = node->sprite->getPosition();
                    Point t = ccp((i+ 0.5)*this->perHeight, (j+0.5)*this->perWidth);
                    if (p.x != t.x || p.y != t.y) {
                        CCActionInterval * moveBy = CCMoveBy::create(0.3,Vec2(t.x-p.x, t.y-p.y));
                        CCActionInterval * actionmoveback= moveBy;
                        node->sprite->runAction(actionmoveback);
                        allNodes->addObject(node);
                    }
                }
            }
            
            
            break;
        }
        default:
            break;
    }
}
Exemple #5
0
/*

// <播放声音可采用,callfunction,这个可以留到以后再做
// <如果有新的效果需求可以在这里添加,限制为ccaction的子类,且只支持单target,设计上是立绘层,不要加入太多的逻辑。

*/
CCAction* ToTextLayer::DerAction(Script* ts, int indent){				
	do{																			
		int targettag = TagMap[ts->getstring("target")];
		const char* type = ts->getstring("type");
		CCAction* t_ca = NULL;
		static map<string,CCAction*> a_map;
		
		if(strcmp(type,"sequence") == 0 || strcmp(type,"spawn") == 0 || strcmp(type,"repeat") == 0){
			int num = ts->m_snum;
			CCArray* sl = ts->scriptnodes;
			CCArray* ss = CCArray::createWithCapacity(num);				//store the actions

			for(int i=0;i<num;i++){
				t_ca = DerAction((Script*) sl->objectAtIndex(i),indent+1);
				ss->insertObject(t_ca,i);				// XML parse error will end unknown throw out here.
			}

			/*
				// <repeat--repeatforever || 当repeat没有子节点时,可以提供name来获取已经定义的action,注意,repeat只接受间隔型操作。
			*/

			if(strcmp(type,"sequence") == 0){
				t_ca = CCSequence::create(ss);
			}else if(strcmp(type,"spawn") == 0){
				t_ca = CCSpawn::create(ss);
			}else if(strcmp(type,"repeat") == 0){		
				int tiTimes;		// <Repeat should be single, multi them by seq or spawn.
				tiTimes = ts->getint("times");
				std::string t_sname;
				t_sname = ts->getstring("name");

				if(strlen(t_sname.c_str())>0) t_ca = a_map[t_sname];		// <提供name将获得优先权
				if(tiTimes>0) 
					t_ca = CCRepeat::create((CCActionInterval*) t_ca,tiTimes);
				else 
					t_ca = CCRepeatForever::create((CCActionInterval*) t_ca);
			}


		}

		/*
			// <如果提供的原始action不是间隔型的话将会出错
		*/

		else if(strcmp(type,"moveby") == 0){
			t_ca = CCMoveBy::create(ts->getfloat("duration"), ccp(ts->getfloat("x"),ts->getfloat("y")));
			CCLOG("move by:%f,%f,%f",ts->getfloat("duration"), ts->getfloat("x"),ts->getfloat("y"));
		}
		else if(strcmp(type,"reverse") == 0){
			t_ca = a_map[ts->getstring("orig")];
			t_ca = ((CCActionInterval*) t_ca)->reverse();						
		}else if(strcmp(type,"moveto") == 0){
			t_ca = CCMoveTo::create(ts->getfloat("duration"), ccp(ts->getfloat("x"),ts->getfloat("y")));
			CCLOG("move to:%f,%f,%f",ts->getfloat("duration"), ts->getfloat("x"),ts->getfloat("y"));
		}else if(strcmp(type,"place") == 0){
			t_ca = CCPlace::create(ccp(ts->getfloat("x"),ts->getfloat("y")));
		}else if(strcmp(type,"scaleto") == 0){
			t_ca = CCScaleTo::create(ts->getfloat("duration"), ts->getfloat("x"),ts->getfloat("y"));
		}else if(strcmp(type,"scaleby") == 0){
			t_ca = CCScaleBy::create(ts->getfloat("duration"), ts->getfloat("x"),ts->getfloat("y"));
		}else if(strcmp(type,"tintto") == 0){
			t_ca = CCTintTo::create(ts->getfloat("duration"), ts->getint("r"), ts->getint("g"), ts->getint("b"));
		}else if(strcmp(type,"tintby") == 0){
			t_ca =  CCTintBy::create(ts->getfloat("duration"), ts->getint("r"), ts->getint("g"), ts->getint("b"));
		}else if(strcmp(type,"rotateby") == 0){
			t_ca = CCRotateBy::create(ts->getfloat("duration"), ts->getfloat("x"),ts->getfloat("y"));
		}else if(strcmp(type,"rotateto") == 0){
			t_ca =  CCRotateTo::create(ts->getfloat("duration"), ts->getfloat("x"),ts->getfloat("y"));
		}else if(strcmp(type,"fadeto") == 0){
			t_ca =  CCFadeTo::create(ts->getfloat("duration"), ts->getint("alpha"));
		}
		else if (strcmp(type, "textauto") == 0){
			t_ca = CCSequence::createWithTwoActions(CCDelayTime::create(ts->getfloat("duration")), CCCallFunc::create(this, callfunc_selector(ToTextLayer::AutoNext)));
		}




		if(indent == 0) {
			CCSprite* p = (CCSprite*) getChildByTag(targettag);
			p->runAction(t_ca);
			a_map.clear();
			/* getChildByTag(targettag)->runAction(tmp); */
		}else{
			string name = ts->getstring("name");
			if(name.length()>0) a_map[ts->getstring("name")] = t_ca;
			return t_ca;
		}
			
	} while(0);
	return false;
}
Exemple #6
0
Script* Scriptor::dump_to_nodes( TiXmlNode* pParent, unsigned int indent, ScriptType st)
{
	if ( !pParent ) return NULL;

	ScriptType tp = st;
	TiXmlNode* pChild;
	TiXmlText* pText;
	int t = pParent->Type();

	CCDictionary* ct = NULL;
	CCArray* ca = NULL;
	CCDictionary* cd = NULL;

	switch ( t )
	{
	case TiXmlNode::DOCUMENT:
		CCLOG( "-Document" );
		break;

	case TiXmlNode::ELEMENT:
		{
			const char* el_name = pParent->Value();
			CCLOG( "Element [%s]", el_name );
		
			if(strcmp(el_name,"pack") == 0) tp = sFilePack;
			else if(strcmp(el_name,"lock") == 0) tp = sLock;
			else if(strcmp(el_name,"list") == 0) tp = sList;
			else if(strcmp(el_name,"png") == 0) tp = sReadFile;
			else if(strcmp(el_name,"scripts") == 0) tp = sScriptPack;
			else if(strcmp(el_name,"text") == 0) tp = sShowText;
			else if(strcmp(el_name,"act") == 0) tp = sAct;
			else if(strcmp(el_name,"select") == 0) tp = sSelect;
			else if(strcmp(el_name,"choice") == 0) tp= sChoice;
			else if(strcmp(el_name,"loadimg") == 0) tp = sLoadImg;
			else if(strcmp(el_name,"action") == 0) tp = sAction;
			else if(strcmp(el_name,"final") == 0) tp = sFinal;		
			else if(strcmp(el_name,"silent") == 0) tp = sSilent;
			else if(strcmp(el_name,"item") == 0) tp = sItem;
			else if(strcmp(el_name,"mapscp") == 0) tp = sMapscp;
			else if(strcmp(el_name,"change") == 0) tp = sChange;
			else if(strcmp(el_name,"mapaction") == 0) tp = sMapAction;


			ct = dump_attribs_to_nodes(pParent->ToElement(), indent+1,tp);	//num of attrib
		
			break;
		}
	case TiXmlNode::COMMENT:
		CCLOG( "Comment: [%s]", pParent->Value());
		break;

	case TiXmlNode::UNKNOWN:
		CCLOG( "Unknown" );
		break;

	case TiXmlNode::TEXT:
		pText = pParent->ToText();
		CCLOG( "Text: [%s],we do not use text.", pText->Value() );
		break;

	case TiXmlNode::DECLARATION:
		CCLOG( "-Declaration" );
		break;
	default:
		break;
	}

	bool t_bNeedRet = true;
	int m = 0;
	CCLOG("----One sccin.Indent:%d----",indent);
	if(ct != NULL){													
		CCInteger* cod = (CCInteger*) ct->objectForKey("total");	//a_这里只_读取script,_mapscp不_提供total属性。
		if(NULL != cod)
		{
			int ccon = cod->getValue();								
			CCLOG("---Indent:%d||Total:%d---",indent,ccon);

			ca = new CCArray(ccon);
			 pChild = pParent->FirstChild();
			for(;m<ccon;m++)
			{
				Script* mtm = dump_to_nodes( pChild, indent+1, tp);
				ca->insertObject(mtm,m);
				mtm->release();
				pChild = pChild->NextSibling();
			}

		}
	}
	int k = 0;
	if(m<1)
	{
		
		ca = new CCArray();
		cd = new CCDictionary();
		for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) 
		{
			if(tp == sMapscp){
				Script* mtm = dump_to_nodes(pChild, indent+1, sNameNode);
				cd->setObject(mtm,mtm->getstring("name"));
				mtm->release();
				CCLOG("---Indent:%d||NT,sMapscp:%s---",indent,mtm->getstring("name"));
				k++;
			}else if(tp == sNameNode){
				Script* mtm = dump_to_nodes(pChild, indent+1, sTypeNode);
				cd->setObject(mtm,mtm->getint("type"));
				mtm->release();
				CCLOG("---Indent:%d||NT,sNameNode:%d---",indent,mtm->getint("type"));
				k++;
			}else if(tp != sUnknown)											//_以上为msp的读入
			{
				Script* mtm = dump_to_nodes( pChild, indent+1, tp);
				ca->insertObject(mtm,k);
				mtm->release();
				CCLOG("---Indent:%d||NT,sUnknown:%d---",indent,k);
				k++;
			}
			else{
				CCLOG("-Per sable Leak,sUnknown Node:%d",indent);
				dump_to_nodes( pChild, indent+1, tp);
				
			}
			
			
		}	

	}


	Script* tmps = new Script();
	if(k+m > 0) {
		if(!ct) ct = new CCDictionary();
		if(m==0){
			CCInteger* t_i = new CCInteger(k);
			ct->setObject(t_i,"total");
			t_i->release();
		}


		tmps->scriptnodes = ca;
		tmps->mapscpnodes = cd;
	}else{							
		CCLOG("-Leaf Node Detect");

		CC_SAFE_RELEASE_NULL(ca);
		CC_SAFE_RELEASE_NULL(cd);
	}

	tmps->m_snum = k + m;
	tmps->attributes = ct;	
	tmps->type = tp;

	switch(tp){
	case sFilePack:
		{
			initcs->addObject(tmps);
			tmps->release();
			in++;
			return NULL;
		}
	case sUnknown:
		{
			CC_SAFE_RELEASE_NULL(tmps);
			return NULL;
		}
	case sScriptPack:
		{
			m_caScript = ca;
			//if(ca) ca->retain();
			sn = k + m;
			tmps->scriptnodes = NULL;
		}
	case sList:
		{
			initcs->addObject(tmps);
			tmps->release();
			in++;
			return NULL;
		}
	case sMapscp:
		{
			mapscps = cd;
			//if(cd) cd->retain();
			tmps->mapscpnodes = NULL;
			CC_SAFE_RELEASE_NULL(tmps);
			return NULL;
		}
	default:
		{
			return tmps;

		}
	}


}
KDbool Ch7_SideScrollingPathfinding::init ( KDvoid )
{	
	// Set game area size
	m_tGameAreaSize = ccp ( 1000 / PTM_RATIO, 600 / PTM_RATIO );		// Box2d units

	if ( !GameArea2D::init ( ) )
	{
		return KD_FALSE;
	}
	m_pMessage->setString ( "Tap the screen move the actor to that point.\nTap again to queue another waypoint." );

	// Set 2D side scrolling gravity
	m_pWorld->SetGravity ( b2Vec2 ( 0, -20.0f ) );
	
	// Add three platforms 
	this->addBoxAtPoint ( ccp ( 625, 200 ), ccs ( 200, 50 ) );
	this->addBoxAtPoint ( ccp (  75, 300 ), ccs ( 230, 50 ) );
	this->addBoxAtPoint ( ccp ( 125, 100 ), ccp ( 220, 50 ) );

	// Create Actor
	this->addActor ( );
	
	// Add draw layer
	this->addDrawLayer ( );
	
	// Create level boundaries
	this->addLevelBoundaries ( );
	
	// Initial variables
	m_fCameraZoom = 0.45f;
	
	// Create SSAStarNodes 
	m_pNodes = new CCArray ( );
	
	// distance between nodes that the actor can run between
	KDfloat		fNodeRunDistInterval = 100.0f;
	
	// How far to search for nodes the actor can jump to
	KDfloat		fMaxJumpSearchDist = 500.0f;
	
	// Add some nodes to the bottom of the level
	for ( KDfloat x = 20.0f; x <= m_tGameAreaSize.cx * PTM_RATIO - 20.0f; x += fNodeRunDistInterval )
	{
		SSAStarNode*	pNode = SSAStarNode::create ( );
		pNode->setPosition ( ccp ( x, 20.0f ) );
		pNode->setBody ( m_pLevelBoundary->getBody ( ) );
		pNode->setActor ( m_pActor );
		m_pNodes->addObject ( pNode );
	}
	
	// Link those nodes together as 'run neighbors'
	for ( KDuint i = 0; i < m_pNodes->count ( ) - 1; i++ )
	{
		SSAStarNode*	pN1 = (SSAStarNode*) m_pNodes->objectAtIndex ( i );
		SSAStarNode*	pN2 = (SSAStarNode*) m_pNodes->objectAtIndex ( i + 1 );
		
		this->linkRunNeighbor ( pN1, pN2 );
	}
	
	// Add nodes to all level platforms 
	for ( b2Body* pBody = m_pWorld->GetBodyList ( ); pBody; pBody = pBody->GetNext ( ) )
	{		
		if ( pBody->GetUserData ( ) != KD_NULL ) 
		{			
			GameObject*		pObject = (GameObject*) pBody->GetUserData ( );
			
			if ( pObject->getTag ( ) == GO_TAG_WALL && pObject->getPolygonShape ( ) )
			{				
				// Nodes on this body only
				CCArray*	pNodesThisBody = CCArray::create ( );
				
				// Process each polygon vertex
				b2PolygonShape*		pShape = pObject->getPolygonShape ( );
				for ( KDint i = 0; i < pShape->m_vertexCount; i++ )
				{					
					b2Vec2		tVertex = pShape->m_vertices [ i ];
					
					// All nodes are 1 unit above their corresponding platform
					b2Vec2		tNodePosition = b2Vec2 ( tVertex.x + pBody->GetPosition ( ).x, tVertex.y + pBody->GetPosition ( ).y + 1.0f );
					
					// Move nodes inward to lessen chance of missing a jump
					if ( pShape->m_centroid.x < tVertex.x )
					{
						tNodePosition = b2Vec2 ( tNodePosition.x - 0.5f, tNodePosition.y );
					}
					else
					{
						tNodePosition = b2Vec2 ( tNodePosition.x + 0.5f, tNodePosition.y );
					}
			
					// If this node position is not inside the polygon we create an SSAStarNode
					if ( !pShape->TestPoint ( pBody->GetTransform ( ), tNodePosition ) ) 
					{			
						SSAStarNode*	pNode = SSAStarNode::create ( );
						pNode->setPosition ( ccp ( tNodePosition.x * PTM_RATIO, tNodePosition.y * PTM_RATIO ) );
						pNode->setBody ( pBody );
						pNode->setActor ( m_pActor );
						m_pNodes->addObject ( pNode );
						pNodesThisBody->addObject ( pNode );
					}					
				}				
				
				// Add in-between nodes (for running)
				KDbool	bDone = KD_FALSE;
				while ( !bDone )
				{
					if ( pNodesThisBody->count ( ) == 0 )
					{
						break; 
					}
				
					bDone = KD_TRUE;
					for ( KDuint i = 0; i < pNodesThisBody->count ( ) - 1; i++ )
					{					
						SSAStarNode*	pNode1 = (SSAStarNode*) pNodesThisBody->objectAtIndex ( i );
						SSAStarNode*	pNode2 = (SSAStarNode*) pNodesThisBody->objectAtIndex ( i + 1 );
							
						if ( GameHelper::absoluteValue ( pNode1->getPosition ( ).y - pNode2->getPosition ( ).y ) > 0.1f )
						{
							// These are not side by side
							continue;
						}
						
						if ( GameHelper::distanceP1 ( pNode1->getPosition ( ), pNode2->getPosition ( ) ) > fNodeRunDistInterval )
						{
							
							CCPoint		tMidPoint = GameHelper::midPointP1 ( pNode1->getPosition ( ), pNode2->getPosition ( ) );
							b2Vec2		tMp = b2Vec2 ( tMidPoint.x / PTM_RATIO, tMidPoint.y / PTM_RATIO );
							
							//If node is not in the polygon, add it
							if ( !pShape->TestPoint ( pBody->GetTransform ( ), tMp ) )
							{
								SSAStarNode*	pNode = SSAStarNode::create ( );
								pNode->setPosition ( GameHelper::midPointP1 ( pNode1->getPosition ( ), pNode2->getPosition ( ) ) );
								pNode->setBody ( pBody );
								pNode->setActor ( m_pActor );
								pNodesThisBody->insertObject ( pNode, i + 1 );
								m_pNodes->insertObject ( pNode, m_pNodes->indexOfObject ( pNode2 ) );
								bDone = KD_FALSE;
								break;
							}		
						}						
					}							
				}
								
				// Link all of the neighboring nodes on this body
				for ( KDuint i = 0; i < pNodesThisBody->count ( ) - 1; i++ )
				{
					if ( pNodesThisBody->count ( ) == 0 )
					{
						break; 
					}
				
					SSAStarNode*	pNode1 = (SSAStarNode*) pNodesThisBody->objectAtIndex ( i );
					SSAStarNode*	pNode2 = (SSAStarNode*) pNodesThisBody->objectAtIndex ( i + 1 );
				
					if ( GameHelper::absoluteValue ( pNode1->getPosition ( ).y - pNode2->getPosition ( ) .y ) > 0.1f )
					{
						// These are not side by side
						continue;
					}
					
					// Two-way link
					this->linkRunNeighbor ( pNode1, pNode2 );
				}				
			}			
		}
	}
		
	// Neighbor all other nodes (for jumping)
	for ( KDuint i = 0; i < m_pNodes->count ( ); i++ )
	{
		for ( KDuint j = 0; j < m_pNodes->count ( ); j++ )
		{
			if ( i == j )
			{
				continue; 
			}
		
			SSAStarNode*	pNode1 = (SSAStarNode*) m_pNodes->objectAtIndex ( i );
			SSAStarNode*	pNode2 = (SSAStarNode*) m_pNodes->objectAtIndex ( j );
		
			if ( pNode1->getBody ( ) == pNode2->getBody ( ) )
			{
				continue; 
			}
		
			if ( GameHelper::distanceP1 ( pNode1->getPosition ( ), pNode2->getPosition ( ) ) <= fMaxJumpSearchDist )
			{
				CCPoint		tSrc = ccp ( pNode1->getPosition ( ).x / PTM_RATIO, pNode1->getPosition ( ).y / PTM_RATIO );
				CCPoint		tDst = ccp ( pNode2->getPosition ( ).x / PTM_RATIO, pNode2->getPosition ( ).y / PTM_RATIO );
				
				// Calculate our jump "launch" vector
				Vector3D*	pLaunchVector3D = SSGameActor::canJumpFrom ( tSrc, tDst, m_pActor->getCircleShape ( )->m_radius * 1.5f, m_pWorld, m_pActor->getMaxSpeed ( ) );
				
				if ( pLaunchVector3D )
				{
					// Only neighbor up if a jump can be made
					// 1-way link
					if ( !pNode1->containsNeighborForNode ( pNode2 ) )
					{
						SSNeighborNode*		pNeighbor = SSNeighborNode::create ( );
						pNeighbor->setLaunchVector ( ccp ( pLaunchVector3D->x, pLaunchVector3D->y ) );
						pNeighbor->setNode ( pNode2 );
						pNeighbor->setMoveType ( MOVE_TYPE_JUMP );
						pNeighbor->setCost ( pNode1->costToNeighbor ( pNeighbor ) );
						pNode1->getNeighbors ( )->addObject ( pNeighbor );
					}
				}
			}
		}
	}
	
	return KD_TRUE;
}