Programming/Cocos2D-X
removeChild 맵에 필요없는 블록 삭제
휘탱
2015. 4. 25. 09:32
cocos2d에서는 delete로 지우지 않는다. removeChild로 도화지에 붙은걸 땐다는 느낌이다.
if( _type == ERASER){
for( int i = 0; i < MAX_BLOCK; i++ ){
if( m_pBlock[i] == NULL)continue;
if( posCompare( _pos, m_pBlock[i]->getPosition() ) ){
m_allTile->removeChild(m_pBlock[i], true);
m_pBlock[i] = NULL;
break;
}
}
}
bool BlockManager::posCompare(CGPoint _Apos, CGPoint _Bpos)
{
int x = _Apos.x / 32, y = _Apos.y / 32;
_Apos = ccp(x*32, y*32);
if( _Apos.x == _Bpos.x && _Apos.y == _Bpos.y )
return true;
return false;
}
맵툴이 완성되었다.
삭제 생성 저장 가능
반응형