-
Notifications
You must be signed in to change notification settings - Fork 491
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
shuffle method doesn't preserve unique properties #484
Comments
I will try that soon and let you know. Thanks for responding, btw the name samme is familiar, i guess you're pretty active in the phaser community? @samme |
this.theTileMap.setPreventRecalculate(true) i tried this and it isn't quite working |
I tried setting it to true, then shuffle, then set it to false, and the opposite and neither worked |
I tried something similar on https://samme.github.io/phaser-examples-mirror/tilemaps/shuffle%20tiles.html: layer.debug = true
map.setCollisionByExclusion([30], true) Then I clicked on the map to shuffle the tiles. The collision faces didn't change. I didn't use the Re. the original post: I haven't tried to reproduce that, but it's possible that calling shuffle inside a tile callback might give unexpected results. |
@samme im not sure i understand |
Maybe I misunderstood. In https://codepen.io/samme/pen/vdzjXy, after you shuffle tiles, do you want the collision lines (green) to change or stay the same? |
@samme i'll elaborate, I'm using the same shuffle method and arguments. What i'm doing is in tiled, i have set properties on the tiles. like lets say one tile is a goal for the player to reach, before the game starts i can iterate through the tiles and store the tile that has a property of "tile_type: 'goal'" as a variable to reference during the game. when i use the shuffle method, VISUALLY the "goal" tile is in a different location, but, the tile that has that property is still in the original location of the goal tile before the shuffle. |
I did the shuffle before finding and storing the "goal" tile by the way. |
like the goal tile is now whatever random tile got put in it's place, so instead of looking like the goal, it's just blank ground. And the tile that visually is the goal tile, does not have that property anymore |
that's an example to illustrate what is happening |
https://jamesjsewell.github.io/sifter/ this is the game i'm making, i am trying to shuffle the inner 4 x 4 tiles. I start in tiled by creating a puzzle that is possible, and then have the app shuffle the puzzle for the user to solve |
OK. It looks like shuffle modifies tile indexes only, it doesn't actually move the tiles around, so that's why the tile data doesn't change as well. swap works the same way. You could try putTile and removeTile. Unfortunately you have to handle the shuffle part yourself. |
@samme interesting, i suppose i could write a function to do that myself, maybe I could make a pr? I've never actually made a pull request to a project like this though |
Clarified the expected behavior in the Tilemap docs. You can still add a new feature if you like. |
the issue is described here by someone, they never got an answer
http://www.html5gamedevs.com/topic/12946-tilemap-shuffle/
"I'm having trouble using Phaser's TileMap.shuffle. When I use it, it shuffles the area of tiles like it should, but the tiles lose their unique properties after being shuffled. Is there some way I can shuffle tiles without losing collision properties? I'm using shuffle like this:
myTileMap.setCollision(tileID, true, layer); // set a few collisions
myTileMap.setTileIndexCallback(tileID, function (player, tile) { // I have two callbacks
// do stuff
When the callback runs, the 5x5 area on the map loses its specific tile properties. Inside the callback, I can re-set the collision tiles, but I can't rewrite the callback I am in. Is there another way I should be going about achieving this? Thank you."
The text was updated successfully, but these errors were encountered: