-3

I have created a tile map of 8x8 matrices,where each tile having sprite. After deleting a sprite from a tile,the upper sprite will take the position of deleted sprite,for that how to find the tile is empty in cocos2d-x 2.2.3

4

1 回答 1

0

步骤1

为您的瓦片地图创建单独的类。

为类创建对象并为磁贴状态分配适当的值。

第2步

声明新的 titeArray 并将精灵添加到 titeArray...

例如

 TileData *tile = [[TileData alloc] init];
 sprite.userObject = tile;
 [tileArray addObject:sprite];

触控功能

-(void) touchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
   for (int i = 0; i < [tileArray count]; i++) 
     {

        if (CGRectContainsPoint( [[tileArray objectAtIndex:i]  boundingBox], touchLoc)) {
           //Game logic like remove your tile or do some functionality.
        }
     }
}
于 2014-08-05T09:10:49.343 回答