Comments (2)
Looks like I need to rework the TiledLayerObject.coordinateForPoint
method.
The reason for this is because of the difference in coordinate systems between SpriteKit and Tiled. Internally, the conversion between screen points & tile coordinate is happening in Tiled's coordinate space, and converted by the coordinateForPoint
& pointForCoordinate
methods.
If the point (in SpriteKit coordinate space) is (216.0, -24.0), the floor operation incorrectly returns 2 because floor(-24.0 / 16.0)
returns -2 and floor(24.0 / 16.0)
returns 1.
Modifying this code will give you the correct result:
open func coordinateForPoint(_ point: CGPoint) -> CGPoint {
let coordinate = screenToTileCoords(point.invertedY)
return floor(point: coordinate)
}
I'll run a few tests to make sure everything checks out, and push up a fix.
from sktiled.
for now it works. thanks for the awesome framework!
Edit: invertedY is not good. if pixelY is 24 it would be -24 and we have the same problem again.
if (pixelY < 0) {pixelY += 16}
fixes my Problem
from sktiled.
Related Issues (20)
- 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
- Wrong ID number for tilesets based on tilesets image HOT 4
- 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
- Question: Load TSX fails HOT 1
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.