Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't change tileAt(x,y) #16

Open
leandersantosm opened this issue Apr 9, 2018 · 3 comments
Open

Can't change tileAt(x,y) #16

leandersantosm opened this issue Apr 9, 2018 · 3 comments

Comments

@leandersantosm
Copy link

Hi, I'm trying to change a image of a tile, but it does not change.
I don't know if I'm doing the right way.
Can someone please help me?

@mfessenden
Copy link
Owner

What you'll need to do is query a tile from its parent layer and set a new texture:

if let tile = tileLayer.tileAt(1, 12) {
    // create a new texture
    let newTexture = SKTexture(imageNamed: "myTexture")
    // set texture filtering 
    newTexture.filteringMode = .nearest
    // update texture & size
    tile.texture = newTexture
    tile.size = newTexture.size()
}

Hope that helps, please let me know if you have any more questions.

@leandersantosm
Copy link
Author

Perfect!!! Thank you so much!! Your framework is wonderful!!
I'm creating a game with it, and if it goes well at App Store, I will make you a donation as a thankful for making this possible!!
Thanks!!! God bless you!!

@leandersantosm
Copy link
Author

Alright, now I have a new problem.

When I change the texture with this commands, sometimes the new texture seems "behind" the tile above.

Example: if I change tile(2,2), sometimes its texture's zPos is lower then tile(1,1), and textures like buildings will apear behind texture of tile (1,1).

How can I fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants