Schoening Posted June 5, 2013 Share Posted June 5, 2013 Guys.. I am tiling a map, but it is flipped wrongly! I am pretty sure that this would tile correctly in a plain Canvas.The "T" is to error check, and should not display tiles on the Left side..Instead they don't display on top: So the whole thing is flipped, or some evil magic, any clues? var map = [ [s,S,S,S,S,S,S,S,S,S,], [s,S,S,S,S,S,S,S,S,S,], [s,S,S,S,S,S,S,S,S,S,], ["T",S,S,S,S,S,S,S,S,S,], [s,S,S,S,S,S,S,S,S,S,], [s,S,S,S,S,S,S,S,S,S,], [s,S,S,S,S,S,S,S,S,S,], ["T",S,S,S,S,S,S,S,S,S,], [s,S,S,S,S,S,S,S,S,S,], [s,S,S,S,S,S,S,S,S,S,] ]; var map_tile_size = 32; var map_offset = 48; var sandTile = PIXI.Texture.fromImage("sand.png"); // Spawn Tiles based on the Map Array: for(var x = 0; x < map.length; x++){ for(var y = 0; y < map[x].length; y++){ if(map[x][y] === S){ map[x][y] = new PIXI.Sprite(sandTile); // center the sprites anchor point map[x][y].anchor.x = 0.5; map[x][y].anchor.y = 0.5; // move the sprite t the center of the screen map[x][y].position.x = x * map_tile_size + map_offset; map[x][y].position.y = y * map_tile_size + map_offset; stage.addChild(map[x][y]); map[x][y].setInteractive(true); } } } Quote Link to comment Share on other sites More sharing options...
rich Posted June 5, 2013 Share Posted June 5, 2013 Your map and loop order's don't appear to match. You want to iterate through y then x inside of that, not the other way around. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.