Giter Club home page Giter Club logo

Comments (4)

mfessenden avatar mfessenden commented on June 7, 2024 2

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.

aornano avatar aornano commented on June 7, 2024

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.
Screenshot 2020-11-05 at 14 39 48
Screenshot 2020-11-05 at 14 40 06

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.

aornano avatar aornano commented on June 7, 2024

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:

Screenshot 2020-11-06 at 15 27 13

So this is not a bug, this report can be closed. Thank you.

from sktiled.

mfessenden avatar mfessenden commented on June 7, 2024

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:

Ismoetric Preview

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:

Missing Tile

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.