5

我通过将宽度和高度的大小更改为对象的两倍大小和位置来遵循将平铺地图转换为视网膜显示的指南。但正常显示的结果与视网膜显示的结果不同正常显示是正确的但视网膜显示不正确

这是非视网膜平铺图 在此处输入图像描述

这是视网膜平铺图 在此处输入图像描述

我还将 -hd 后缀添加到视网膜 .tmx 文件中

有什么不对?

4

1 回答 1

6

Me also observed same problem with cocos2D tile map and finally resolved by dividing CC_CONTENT_SCALE_FACTOR. In retina mode it gives 2.0.

CCTMXObjectGroup *objects = [tileMap objectGroupNamed:NN_TILE_MAP_OBJECT_LAYER];

CGSize s = [[CCDirector sharedDirector] winSize];

NSMutableDictionary *newtonPos = [objects objectNamed:NN_NEWTON_POS];        

if(newtonPos)
{
    float x = ([[newtonPos valueForKey:@"x"] floatValue])/CC_CONTENT_SCALE_FACTOR();
    float y = [[newtonPos valueForKey:@"y"] floatValue]/CC_CONTENT_SCALE_FACTOR();

    MyGameScreen *p = (MyGameScreen*)self.parentLayer;
    p.gameActor.position = ccp(x, y);
}

//I used this function to get chord..

- (CGPoint)getTileCoordForPosition:(CGPoint)position
{
    int maxTileCol = self.mapSize.height; 

    int x = ( (position.x-self.position.x)/TILE_SIZE);
    int y = maxTileCol - ( ((position.y)-self.position.y)/TILE_SIZE);

    if( x >= TILE_IN_ROW)
        x = TILE_IN_ROW - 1;

    if( y >= TILE_IN_COL)
        y = TILE_IN_COL - 1;

    return ccp(x, y);

}
于 2012-10-11T13:26:58.293 回答