Comments (4)
Do you have a sample scene you can send me to illustrate the problem?
The global id (gid) represents the tile data's internal id plus the tileset's firstGID
value. Internally, the tileset stores tile data in an array starting with 0 with the upper bound being the number of tiles.
The value stored in the map file is the global id, so the SKTileset.getLocalID(forGlobalID :)
method is used to resolve the global id → local id.
from sktiled.
Ok Michael, I've created a repository to reproduce this bug with a README that show all images:
https://github.com/aornano/SKTiledBugged
This tileset started with ID 0 for the first upper left tile.
As you can see to these screenshots , I've try to put the grass tile as showed in the editor but in the app it appear with the previous tile (the grass with the stones).
So it takes the ID 3 instead of ID 4.
That's the tilesets TSX file (xml) file :
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.4" tiledversion="1.4.2" name="grass1" tilewidth="128" tileheight="64" margin="1" tilecount="9" columns="3">
<image source="handpainted.png" width="512" height="256"/>
</tileset>
Thank you for your reply!
from sktiled.
Ok I've found the problem.
This issue is not from your code, your code is correct.
The problem is the default value of TiledMap Editor v1.4.2 when you create the TSX file:
So this is not a bug, this report can be closed. Thank you.
from sktiled.
The problem actually lies within your tileset file.
I noticed in your second post that the image you were loading was too large for a 3x3 tileset at 128x64px. I changed this...
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.4" tiledversion="1.4.2" name="grass1" tilewidth="128" tileheight="64" margin="1" tilecount="9" columns="3">
<image source="handpainted.png" width="512" height="256"/>
</tileset>
... to this...
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.4" tiledversion="1.4.2" name="grass1" tilewidth="128" tileheight="64" tilecount="16" columns="4">
<image source="handpainted.png" width="512" height="256"/>
</tileset>
...and the preview in Tiled now matches what you're seeing in your iOS app:
When the SKTileset
loads in your source spritesheet image, I'm calculating the bounding rect for each tile based on the total tile count, the source image dimensions and spacing/margin values. So in SKTiled, the tile with id 3 is actually this guy:
Bjorn is creating his tileset images a little differently, so you've given me a great use-case for reviewing how we calculate our tile breakup 😉
Technically, this is a bug so I'll keep it closed, but will add it to the list of things to fix.
from sktiled.
Related Issues (20)
- Animations in code HOT 5
- please add infinite maps and random map!
- Large tile maps not rendering correctly HOT 3
- Documentation site install to dash button has wrong URL HOT 1
- SKTile highlight color is defined by frameColor HOT 2
- The tvOS target is not part of the Podspec in the cocoapods master repo HOT 1
- function addTilesetTile of SKTileset.swift crash with nil HOT 1
- Would Apple Watch support be possible? Just asking :) HOT 1
- addTileAt not replacing tile properly HOT 2
- Loading new tilemap memory leak HOT 8
- Can I get that the user clicked on a certain location on the map? HOT 3
- objective-c compatibility? HOT 1
- M1 Mac Xcode12 HOT 4
- Scaling of Objects HOT 2
- SKTileMapNode vs SKTiled performance question HOT 8
- Questions: player, enemies; collision detection?
- Feature request: get tile coord from SKTile object
- Memory issues when presenting new SKTiledScene, small on iOS, larger on macOS
- [Solved] Some nodes disappear with the framework
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sktiled.