glass22 Posted December 26, 2013 Share Posted December 26, 2013 1. How can I clear all sprites? is there a automated way to do this? 2. How can I make levels and then import the data? is there any tutorial on doing this? never done games before. 3. I'm currently using png images but of course the game has a bounding box that doesn't take into account transparency, is there any way of solving this? except for drawing shapes etc? and using them for collision detection? 4. Is there any way to save a game world? and reload it? other than by doing it manually? -- P.S - this is a really, really good engine. Link to comment Share on other sites More sharing options...
MisterMaSK Posted December 26, 2013 Share Posted December 26, 2013 1.if you want to remove everything displayed in the screen, you can use - game.world.removeAll();else if you just want to remove all displayed sprites of a group (and not delete the group itself), you can use - game.groupName.forEach(function(item) {item.kill();});2.phaser supports tilemap import, if thats what you mean - http://gametest.mobi/phaser/examples/_site/view_full.html?d=tilemaps&f=fill+tiles.js&t=fill%20tileslook around in the examples for more. you can import different tilemaps for different levels. use Tiled to make them. you can also use different states for different levels. have a look in the 'resources\Project Templates\Basic' folder for a sample template for better understanding of the states. 3. i think they are already working on better collisions. 4. i couldn't find a way when i wanted it so.. i just took the necessary data (in this case it was player position and score) and sent it to a php file and with that php file i save it to the db. so while loading the game if the player enters his username i check if he exists in the database and if yes i fetch his data and apply it... -- P.S. this IS a really good engine, 3-4 days in i have made like 3 good small games that i wanted to make since forever. and now i am working on a big one. BitlasLT 1 Link to comment Share on other sites More sharing options...
glass22 Posted December 26, 2013 Author Share Posted December 26, 2013 Ok thanks a lot, Link to comment Share on other sites More sharing options...
ragnarok Posted December 26, 2013 Share Posted December 26, 2013 Don't know if this is helpful, but currently I'm exporitng/importing my Leveldata not with phaser but with crude HTML5. My solution (ab)uses the "download"-tag of HTML5's anchortag. The following proof of concept it let's you save a levelobject, manipulate said object (by corrupting it) and reload the object from file. Works on Chrome at least. You should of course do something different with the leveldata, than corupting it.<!DOCTYPE html><html> <head> <script> var levelData = { tiles:[[1,2],[3,4]], score: 1500 } function exportData() { fileData = 'data:application/JSON;charset=utf-8,' + encodeURIComponent(JSON.stringify(levelData)); document.getElementById('btnExport').href=fileData; document.getElementById('btnExport').click(); } function importData(event) { var selectedFile = event.target.files[0]; var reader = new FileReader(); reader.onload = function(event) { var data=event.target.result.replace(/[^,]*,/,''); data=JSON.parse(atob(data)); levelData=data; }; reader.readAsDataURL(selectedFile); } </script> </head> <body> <a href="#" download="level.JSON" id="btnExport" target="_blank" style="display:none;">Placeholder</a> <input type="button" onclick="exportData()" value="Save Data"/> <br><input type="button" onclick="levelData='corrupt'" value="Destroy Data!"/> <br>Load Data:<input type="file" onchange="importData(event)"/> </body></html> Link to comment Share on other sites More sharing options...
glass22 Posted December 27, 2013 Author Share Posted December 27, 2013 Yeah that's what I was planning on doing. Link to comment Share on other sites More sharing options...
Recommended Posts