【发布时间】:2015-05-01 07:57:21
【问题描述】:
我刚刚创建了一个在用户触摸位置创建对象的函数,但我希望它根据我的平铺地图自动与平铺的中心对齐。
现在,我只能将对象放置在我的触摸位置,而不是自动将其重定向到最近的图块。
http://puu.sh/ggxOG/2785a2eeca.png(这就是我的瓷砖看起来像 32x32)
JSTileMap 函数
@class JSTileMap;
@interface TMXLayer : SKNode
@property (strong, nonatomic) TMXLayerInfo* layerInfo;
@property (strong, nonatomic) NSMutableSet* tileInfo; // contains TMXTilesetInfo objects
@property (assign, nonatomic) CGSize mapTileSize;
/** Returns the width of the layer (layerGridSize.width * mapTileSize.width) */
@property (readonly,nonatomic) CGFloat layerWidth;
/** Returns the height of the layer (layerGridSize.height * mapTileSize.height) */
@property (readonly,nonatomic) CGFloat layerHeight;
/** Returns the JSTileMap that contains this layer */
@property (weak, nonatomic) JSTileMap* map;
- (CGPoint)pointForCoord:(CGPoint)coord;
- (CGPoint)coordForPoint:(CGPoint)point;
- (void)removeTileAtCoord:(CGPoint)coord;
- (SKSpriteNode*)tileAt:(CGPoint)point;
- (SKSpriteNode*)tileAtCoord:(CGPoint)coord;
- (int)tileGidAt:(CGPoint)point;
- (id)propertyWithName:(NSString*)name;
- (NSDictionary*)properties;
@end
【问题讨论】:
-
您能否与我分享您解决此问题的最终代码
标签: ios xcode swift tiled jstilemap