Paul-Andre Posted August 15, 2013 Share Posted August 15, 2013 Oh, please forgive me if I'm missing something so obvious here. I wish to use Phaser from Javascript and I don't know where to start, and since there is no API documentation, I'm completely lost. The test suit is something, but there are multiple things that I don't really get.For example, if I'd like to create a TileMap and populate it grammatically, what should I do?Also, are there some complete game examples or tutorials in Javascript that I could play with? Everything I find seems to be for Typescript. Link to comment Share on other sites More sharing options...
rich Posted August 15, 2013 Share Posted August 15, 2013 You're not missing anything, I'm afraid the content you're after just doesn't really exist yet. I promise as soon as I'm over my 1.0 release issues that I'll be doing tutorials like crazy (in both JS and TS). In the meantime if you've any specific questions do ask them here and I can help. Link to comment Share on other sites More sharing options...
Paul-Andre Posted August 15, 2013 Author Share Posted August 15, 2013 How would you create a tile map and fill it with random tiles? Link to comment Share on other sites More sharing options...
rich Posted August 15, 2013 Share Posted August 15, 2013 You would prepare your map data in a string that is comma separated. Then create a new Phaser.Tilemap object. For the mapData parameter give it the string you made, and for the format parameter give it the type of Tilemap.FORMAT_CSV. How you randomise that data is up to you. The string should be split on a newline: "\n", i.e.: var data = "1,1,1,11,0,0,11,0,0,11,1,1,1"; Or: var data = "1,1,1,1\n1,0,0,1\n1,0,0,1\n1,1,1,1"; Link to comment Share on other sites More sharing options...
Paul-Andre Posted August 15, 2013 Author Share Posted August 15, 2013 So there you must absolutely give the constructor some start-up data. Ok. I thought about generating data once it's allready created.Now, what's the difference between new Phaser.Tilemap and myGame.createTilemap ? Link to comment Share on other sites More sharing options...
rich Posted August 15, 2013 Share Posted August 15, 2013 createTilemap doesn't need you to pass a reference to the Phaser.Game object in, because it already knows about it and uses it. It also adds the tilemap to the display automatically. So if you just wanted to extract data from a map and not actually display it (i.e. use it for collision) then you'd create a new Tilemap object instead. Link to comment Share on other sites More sharing options...
Paul-Andre Posted August 15, 2013 Author Share Posted August 15, 2013 Ok, and is it possible to create a Tilemap with no data, but add it latter, with function calls, once it is already created? I don't see the point of programmatically creating the data string. Link to comment Share on other sites More sharing options...
rich Posted August 15, 2013 Share Posted August 15, 2013 It will need to be seeded with something, but it doesn't matter if that is entirely empty data. Link to comment Share on other sites More sharing options...
Paul-Andre Posted August 15, 2013 Author Share Posted August 15, 2013 Does empty data means an empty string, or just a lot of zeros? Can I make a grid of a certain width and height without having to have a big empty data string? Link to comment Share on other sites More sharing options...
rich Posted August 15, 2013 Share Posted August 15, 2013 A load of zeros. Each tile needs to know how to visually represent itself in-game, even if that's "nothing". You can manipulate the grid data easily post instantiation. But it really is something you'd want to get sorted up front, and not keep changing dimensions dynamically. Link to comment Share on other sites More sharing options...
Recommended Posts