Creates SpriteKit game maps from TMX Map files.

Overview

PEMTileMap is a Swift package that generates SpriteKit game maps from TMX Map files. Maps, layers, tiles and objects are automatically rendered as SKNodes on the SKScene. TMX Map files can be created and edited with Tiled.

Based on the JSTileMap project which was famously used in Ray Wenderlichs SpriteKit SuperKoalio tutorial but no longer seems to be maintained. I hope to make a light-weight framework that supports iOS, macOS and tvOS.

I also made a Swift version of the SuperKoalio game, which uses PEMTileMap to generate the map and also supports iOS, macOS and tvOS.

TMX Features

  • read and parse TMX map files
  • CSV, Base64 layer formats with gzip, zlib or no compression
  • fixed size maps
  • orthogonal map types
  • map background color
  • embedded tile sets
  • tilesets based on a tileset image
  • tilesets based on a collection of images
  • tilesets using a specific color for transparency
  • external TSX tile sets
  • object groups
  • object template files
  • image layers
  • layer groups
  • layer tinting
  • flipped tiles
  • animated tiles
  • properties

Not (yet) supported

  • Zstandard compression
  • world files
  • infinite maps
  • isometric map types
  • isometric staggered map types
  • hexagonal staggered map types
  • terraintypes, wangsets, transformations
  • image <trans> color

PEMTileMap Features

  • Swift code
  • Objective-C compatibility
  • iOS (>13.6), macOS (>10.15), tvOS (>13.4)
  • generate TMX maps as SKNode objects with child elements as SKNode subclasses (eg. a tile as a SKSpriteNode, a polygon object as an SKShapeNode, etc.)
  • both nearest neighbor and linear texture antialiasing
  • camera tilt and zoom
  • access layers, tiles, objects
  • parallax scroll
  • anti-tearing (removing tear lines between tiles)

Known issues

Please refer to the issue tracker on GitHub. All bugs reports, feature requests and comments are welcome.

Documentation

Check out the documentation on this page.

Installation

Swift package

In Xcode project settings, under "Package Dependencies" add the PEMTileMap repository.

URL: https://github.com/hotdogsoup-nl/PEMTileMap.git
Dependency rule: branch
Branch: master

Cocoapods & Carthage

These dependency managers are not supported and will not be supported in the future.

Usage

Loading the map

The tilemap should be loaded in your SKScene referring the map file name and the associated SKView.

  if let newMap = PEMTileMap(mapName: "superkoalio.tmx", view: skView!) {
    // center the map on the screen
    newMap.position = CGPoint(x: newMap.mapSizeInPoints().width * -0.5, y: newMap.mapSizeInPoints().height * -0.5)
    addChild(newMap)
  }

The map will now render and appear on the scene as an SKNode. It will contain child nodes for all TMX Map layers and groups which contain the tiles and other objects as children.

Accessing map functions

PEMTileMap has several public properties and functions that can be use to access map properties such as its orientation, highest used zPosition, map size (in tiles or in points) and for converting scene coordinates to map coordinates and vice versa. Check out the documentation.

Accessing layers, tiles, objects

PEMTileMap has several functions to access layers, tiles, and objects on the map. Check out the documentation.

Using a camera

You are responsible for creating and controlling the camera in your scene. PEMTileMap does however have basic moveCamera functions to move the camera around the map. Set the cameraNode property to point to your camera before calling moveCamera.

Use the background color

To set the background color of your SKScene to match the map background color:

    if newMap.backgroundColor != nil {
        backgroundColor = newMap.backgroundColor!
    }

Build the Demo app

Download the repository and open the PEMTileMap Xcode project. Build any of the iOS, macOS or tvOS targets. Depending on the platform choice, you may get a build error stating that a provisioning profile is required. In "Signing and Capabilities", make sure each target has either automatic signing enabled or select the correct provisioning profile.

If a build error occurs stating Resource fork, Finder information, or similar detritus not allowed there is an issue with image files in the project. Run sudo xattr -cr * on all image file folders in the project and clean the build folder to fix.

License

Licensed under the MIT license.

You might also like...
HxSTLParser is a basic STL parser capable of loading STL files into an SCNNode

HxSTLParser HxSTLParser is a basic STL parser capable of loading STL files into an SCNNode. Installing Via Carthage Just add it to your Cartfile githu

Created a Tic Tac Toe game with pure swift that runs within zsh shell.
Created a Tic Tac Toe game with pure swift that runs within zsh shell.

Swift TicTacToe Created a Tic Tac Toe game with pure swift that runs within zsh shell. The computer is actually really hard to beat and it ends up bei

Challenge... counting game for kids... should be entertaining, educational and fun... o_O
Challenge... counting game for kids... should be entertaining, educational and fun... o_O

MultiTainment Simple multiplication game for kids. Possible to choose how many questions they want to answer and how hard shoud it be. Simple funny in

Flashzilla - Card game for learning and having lot of fun
Flashzilla - Card game for learning and having lot of fun

Flashzilla Flashzilla is a card quiz game. Where you can add (and remove) your o

Demo in SwiftUI of Apple Map, Google Map, and Mapbox map
Demo in SwiftUI of Apple Map, Google Map, and Mapbox map

SNMapServices SNMapServices is a serices for iOS written in SwiftUI. It provides Map capability by subclassing Mapbox, Google map and Apple map. This

An exercise to use a map(google map) for navigation.

map-navigation An exercise to use a map(google map) for navigation. It have the features of navigating your for a destination, drawing your travel pat

An iOS map clustering framework targeting MapKit, Google Maps and Mapbox.
An iOS map clustering framework targeting MapKit, Google Maps and Mapbox.

ClusterKit is an elegant and efficiant clustering controller for maps. Its flexible architecture make it very customizable, you can use your own algor

Card-based view controller for apps that display content cards with accompanying maps, similar to Apple Maps.

TripGo Card View Controller This is a repo for providing the card-based design for TripGo as well as the TripKitUI SDK by SkedGo. Specs 1. Basic funct

🗺️ MAPS.ME — Offline OpenStreetMap maps for iOS and Android
🗺️ MAPS.ME — Offline OpenStreetMap maps for iOS and Android

MAPS.ME MAPS.ME is an open source cross-platform offline maps application, built on top of crowd-sourced OpenStreetMap data. It was publicly released

A Swift package for parsing Clang module map files

Clangler is a Swift package used to parse Clang module map files into an abstract syntax tree (AST) representation. Once parsed, you can inspect or manipulate the nodes in the file, then generate and save a new file reflecting your changes.

iOS Swift Game - Push SpriteKit to the limit
iOS Swift Game - Push SpriteKit to the limit

iOS Swift Project - Legend Wings - EverWing's Mini Clone EverWing is a popular action game. Survive as much you can, earn gold, and upgrade/purchase n

A Component Piece (a game) for a larger app (KoyaQuest) using SpriteKit

NyonindoChallenge This is a game that is intended for inclusion in a larger app (called KoyaQuest). I have created a separate version because of probl

SpriteKit 2D Breakout Game on rotating 3D SceneKit cube almost no code
SpriteKit 2D Breakout Game on rotating 3D SceneKit cube almost no code

2D Breakout game playable as texture on a rotating cube An Xcode12 project for iOS that implements a simple 2D SpriteKit "Break Out" style game. The S

This project is a 2D game for iOS users built with Swift and SpriteKit.
This project is a 2D game for iOS users built with Swift and SpriteKit.

PANDA CLICKER Description Panda Clicker is a 2D game and the aim is to touch the Panda image on the center of the screen. In each touch of the panda i

A simple game application using SpriteKit, physics, blend modes, radians and CGFloat
A simple game application using SpriteKit, physics, blend modes, radians and CGFloat

Pachinko A simple game application using SpriteKit, physics, blend modes, radian

A simple game application for iPad using SpriteKit, SKCropNode
A simple game application for iPad using SpriteKit, SKCropNode

Whack-a-Penguin A simple game application for iPad using SpriteKit, SKCropNode,

Hitting only the bad PinGUYS! Simple SpriteKit game
Hitting only the bad PinGUYS! Simple SpriteKit game

Whack-a-Penguin Hitting only the bad PinGUYS! Simple SpriteKit game. You have to

ShooterGame - An iOS App that is a shooter game. Made with SpriteKit and Swift

Shooter Game This project was created based on the challenge of Day 66 of the 10

AngryBirdClone - Usage SpriteKit for create a AngryBird Game Clone
AngryBirdClone - Usage SpriteKit for create a AngryBird Game Clone

#AngryBird Clone SpriteKit The SpriteKit framework makes it easy to create high-

Owner
hotdogsoup.nl
Check out my YouTube channel!
hotdogsoup.nl
Azure Maps iOS SDK binary distribution for Swift Package Manager

Azure Maps Control for iOS Installation In your Xcode iOS Project settings, under Project setting’s Package Dependencies, click on + button to add pac

Microsoft Azure 2 Nov 1, 2021
SpriteKit API reproducing UIView's spring animations with SKAction

SpriteKit-Spring SpriteKit-Spring is a set of extensions to perform spring animations with SpriteKit. Installation iOS 7 If you need to support iOS 7,

Alexis Taugeron 242 Dec 17, 2022
Zip - A Swift framework for zipping and unzipping files. Simple and quick to use. Built on top of minizip.

Zip A Swift framework for zipping and unzipping files. Simple and quick to use. Built on top of minizip. Usage Import Zip at the top of the Swift file

Roy Marmelstein 2.3k Jan 3, 2023
ZIP Foundation is a library to create, read and modify ZIP archive files.

ZIP Foundation is a library to create, read and modify ZIP archive files. It is written in Swift and based on Apple's libcompression for high performa

Thomas Zoechling 1.9k Dec 27, 2022
Merges a given number of PDF files into one file using the PDFKit framework

Titanium iOS PDF Merge Merges a given number of PDF files into one file using the PDFKit framework Requirements iOS 11+ Titanium SDK 9+ API's Methods

Hans Knöchel 6 Jan 26, 2022
Validate iOS, Android, and Mac localizations. Find errors in .strings, .stringsdict, and strings.xml files.

Locheck An Xcode and Android localization file validator. Make sure your .strings, .stringsdict, and strings.xml files do not have any errors! What do

Asana 73 Dec 13, 2022
Converter for your Rigol Oscilloscope .CSV files to LtSpice

rigol2spice A program to convert Rigol oscilloscope's .CSV files to a format readable by LTspice. Your Rigol oscilloscope can output .CSV files that c

Rui Carneiro 4 Aug 31, 2022
Steps and files needed to reproduce a CSP bug in Safari Web Extensions

CSP Safari bug repro There appears to be a discrepancy between how Safari handles CSP policies for extension pages compared to how other browsers do s

Brian Birtles 0 Nov 6, 2021
Parse iOS mobile provisioning files into Swift models

SwiftyProvisioningProfile This library provides a way to decode a .mobileprovision file into a Swift model. Installation The recommended installation

James Sherlock 60 Nov 25, 2022
Monitor changes to files and directories using kernel event notifications (kqueue) in Swift

SKQueue SKQueue is a Swift libary used to monitor changes to the filesystem. It wraps the part of the kernel event notification interface of libc, kqu

Daniel Pedersen 86 Oct 26, 2022