我遵循将平铺地图转换为 Retina 显示的指南,将宽度和高度的大小也更改为对象的两倍大小和位置.但是正常显示的结果与retina display的结果不一样,正常显示是正确的,但retina显示不正确
I follow guide of converting tile map for retina display by changing size of width and height to double size and position of object too. but the result on normal display is not same as retina display normal display is correct but retina display is not correct
这是非视网膜平铺地图
这是视网膜平铺贴图
我还在视网膜 .tmx 文件中添加了 -hd 后缀
I also add -hd suffix to retinal .tmx file
有什么问题吗?
我也发现cocos2D tile map有同样的问题,最后通过划分CC_CONTENT_SCALE_FACTOR解决了.在视网膜模式下,它提供 2.0.
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);
}
这篇关于当我转换为视网膜显示时,瓷砖地图的位置错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!