游戏开发中的瓦片地图:正交与等距瓦片地图详解
1. 正交瓦片地图滚动
在游戏开发中,瓦片地图的滚动是一个重要的功能。在Tilemap04项目里,实现滚动的关键在于移动 CCTMXTiledMap 。以下是具体实现步骤:
- 获取触摸点的瓦片坐标 :在 ccTouchesBegan 方法中,先获取触摸位置,再将其转换为瓦片坐标。
-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// ...
// Get the position in tile coordinates from the touch location
CGPoint touchLocation = [self locationFromTouches:touches];
CGPoint tilePos = [self tilePosFromLocation:touchLocation tileMap:tileMap];
// Move tilemap so that the touched tile is at the center of the screen
[self centerTileMapOnTileCoord:tilePos tileMap:tileMap];
// ...
}
- 将瓦片地图移动到触摸点的中心 :
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



