Load a .tmx (Tiled Map) in Sprite Kit?
Check out TilemapKit for Sprite Kit. Unlike other solutions it loads and renders all (!) map types and variations supported by Tiled, including staggered iso and hex maps!
TilemapKit is properly engineered like a OOP framework should be, and exposes all data that is stored in the TMX file. In other words it's definitely not just a single class that got everything crammed into it.
Tile picking (point to coord, coord to point conversion) for all map types/variations is built-in. More awesome features on the way, review the roadmap and check out the Class Reference.
TilemapKit is also tested to be fully compatible with Swift and Mac apps, too.
Visit the TilemapKit forum if you have any questions or requests. I'm also posting frequent development reports so you can check what's coming up next.
Disclaimer: If it isn't obvious by now, I'm one of the TilemapKit developers. :)
Fail to see a TMX Map using SpriteKit and JSTileMap
The problem is the @2x on your images. This indicates to SpriteKit that your image is working off of points, not pixels and loads your image as such. The TMX map format works in pixels, not points, and this throws off the expected math. You can verify this by putting a breakpoint in the setSourceImage:
method and looking at the _imageSize variable -- it's cut in half when using the @2x suffix.
Remove the @2x from your images (both in your Xcode project and the TMX map XML) and you should be good to go.
Note that I had to clean once these changes were made to see them reflected in the iPhone simulator.
Sprite Kit : Most efficient way to load a big map (like Limbo/Mario)
You should use a Tile Map for that. It's much faster than loading and drawing the entire map. This tutorial explains how to do that. (Scroll down to "Loading the TMXTiledMap".)
Proper & efficient way of affecting specific tiles in a tiled map
You could try a recursive function with input parameters that indicate the tiles to operate on and depth of recursion and output would be an array of tiles to highlight. So the initial call to the function would include the start tile and depth, then subsequent calls would pass in the adjacent tiles and the depth - 1. When depth reaches 0 you can just return the tiles array and append it to the previous invocation.
This is a draft example. You'll need to provide your own implementation for getAdjacentTiles
and FABTile
is your custom tile.
- (NSArray *)tilesToHighlight:(FABTile *)tile withDepth:(int)depth {
NSMutableArray *result = [NSMutableArray array];
if (depth == 0) {
return result;
}
NSArray *adjacentTiles = [self getAdjacentTiles:tile];
for (FABTile *adjacentTile in adjacentTiles) {
if (![result containsObject:adjacentTile]) {
[result addObject:adjacentTile];
}
NSArray *tilesToHighlight = [self tilesToHighlight:adjacentTile withDepth:depth - 1];
for (FABTile *tileToHighlight in tilesToHighlight) {
if (![result containsObject:tileToHighlight]) {
[result addObject:tileToHighlight];
}
}
}
return result;
}
Call the method like this.
NSArray *tilesToHighlight = [self tilesToHighlight:startTile withDepth:2];
Related Topics
Why Must a Protocol Operator Be Implemented as a Global Function
Conditionally Hide Code from the Compiler
Universal Links Not Working on iOS10
How to Stop and Resume Background Audio from iPhone App
Get Height of iOS Keyboard Without Displaying Keyboard
iOS 9 Cloudkit: Query Does Not Return Anything While Connected to Cellular Network
Firebase Queryorderedbychild() Method Not Giving Sorted Data
How to Lay Out 2 Buttons Vertically on Uialertview
Cgcolorgetcomponents() Not Returning the Correct Values for Black and for White
How to Permanently Allow Usage of Camera on Trusted Websites with iOS - Safari
How to Release an Mtaudioprocessingtap
How to Control Avassetwriter to Write at the Correct Fps
Clip Image to Square in Swiftui
How to Query Nearest Users in Firebase with Swift
iOS 7 Uitoolbar Overriding with Status Bar
Cannot Invoke Initializer for Type 'Double' with an Argument List of Type '(String)'