我遵循将平铺地图转换为 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);
}
上一篇:在 cocos2d 中将多个 CCSprite 组合成一个分组对象组合、多个、中将、对象
下一篇:java.lang.IllegalStateException:指定的孩子已经有一个父。你必须先调用removeView()对孩子的父孩子、必须先、有一个、lang