Retina在cocos2d iphone中显示tilemap碰撞检测 [英] Retina display tilemap collision detection in cocos2d iphone

查看:189
本文介绍了Retina在cocos2d iphone中显示tilemap碰撞检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为简单的显示和视网膜显示创建了两个不同的 tilemap
简单的显示碰撞检测是正确的。当我在视网膜显示地图显示地图显示正确,但碰撞检测不正确。

I have created two different tilemaps for simple display and retina display. Simple display collision detection is proper. When I test it on retina display map display properly but collision detection is not proper.

任何人都可以帮助我。

推荐答案

这里我使用这个函数检查冲突,然后在两个显示中都运行良好。

Here I check for collisions using this function then it runs well in both displays.

- (CGPoint)tileCoordForPosition:(CGPoint)position 
{
    CGFloat scale = [[UIScreen mainScreen] scale];
    NSLog(@"%f",map1.tileSize.height);
    int y = ((map1.mapSize.height * map1.tileSize.height) - position.y*scale) / map1.tileSize.height+(map1.position.y *scale/map1.tileSize.height);
    int x =-((map1.position.x *scale) / map1.tileSize.width)+(MainCharacter.position.x*scale/map1.tileSize.width);
    return ccp(x, y);
}

这篇关于Retina在cocos2d iphone中显示tilemap碰撞检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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