当我转换到视网膜显示时,瓷砖地图的错误位置 [英] wrong position of tile map when i convert to retina display

查看:67
本文介绍了当我转换到视网膜显示时,瓷砖地图的错误位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

这是非视网膜贴图

This is non-retina tile map

这是retina tile map

and this is retina tile map

我还为视网膜.tmx文件添加了-hd后缀

I also add -hd suffix to retinal .tmx file

有什么问题吗?

推荐答案

我也观察到cocos2D瓦片地图的相同问题,最后通过分割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);

}

这篇关于当我转换到视网膜显示时,瓷砖地图的错误位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆