How do I dynamicly load project files with AJAX

Get help using Construct 2

Post » Sun Nov 30, 2014 8:55 pm

Message: beni92 is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
Hi there,

I have a XML File with all the paths to my levels. The pathes to the Levels are paths in the ProjectFiles folder.
img2.PNG


I want to load my level variabl. So if a user clicks on Level 1, I want to load the file "Level1" in my ProjectFiles Folder.
img1.png

As Ashley wrote in this tutorial:
You can also allow yourself to change or add new levels after the game is published, without re-uploading the entire game. For example if you load a list of available levels from an XML file, you only need to upload or change a few .json files then edit the .xml file in order to add or update levels.


But how do I load my Levels from various XML project files if I can't acces them variabl? Do i have to put all my Levels in one single XML file? Are there any known issues with big XML file (arround some MB (like 2 or 3))

Thanks for your help :)

PS: sorry zhat my english is not se yellow from se egg :/

Best regards Beni
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 27
Reputation: 277

Post » Mon Dec 01, 2014 4:25 pm

"WorldOverview" is not a valid XML document. The action you are using expects an XML document starting with the usual "<?xml ...". You can pass any variable that is a valid XML document. You might need to AJAX request a project file first.
Scirra Founder
B
402
S
238
G
89
Posts: 24,628
Reputation: 196,023

Post » Mon Dec 01, 2014 6:08 pm

Sorry maybe I was not clear what i wanted, I did load my XML document with all the pathes, I now want to load each document with the Data inside. The data is in my example a MapData. But with the AJAX Plugin i can only load files if prerender choose which File this should be. I cannot load these Files on runtime dynamcly. So this would mean i can't change after release a path in my XML File and a map.

projectfiles.PNG


As I do it now I'm not satisfied. I load a php file on a server which gives me all my files in directory on the Server. But that would mean that the player has to be always online, and my game is just not that type of game which has to be alwaysonline :/

Is there any way to do this "offline" (which means download once like in your tutorial explained)

Thanks for your help :)
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 27
Reputation: 277

Post » Mon Dec 01, 2014 7:17 pm

I believe project files are exported to a single common folder, so your logic will probably need some fixing.

Anyhow, if you want to load at run time your XML, use the AJAX object's "Request project file" action. Then, on AJAX completed, Load XML -> AJAX.LastData
B
75
S
31
G
27
Posts: 1,014
Reputation: 20,763

Post » Mon Dec 01, 2014 7:24 pm

You can also use AJAX > Request URL :: Then put in the actual URL to the XML document. Like: http://192.168.0.1/subfolder1/subfolder ... erview.xml

Then use AJAX.LastData to read the response.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Mon Dec 01, 2014 9:26 pm

Will this work with the lokal ip 127.0.0.1? Or how does this end up after i export this as a html5 website or on a phone?
B
5
Posts: 27
Reputation: 277

Post » Mon Dec 01, 2014 11:40 pm

All the project files are actually exported flat, to the same folder - the project structure is lost on export. So for example you'd AJAX request just "Level3.xml", without any subfolder.
Scirra Founder
B
402
S
238
G
89
Posts: 24,628
Reputation: 196,023

Post » Tue Dec 02, 2014 6:22 am

Thanks so much, you helped me a lot :)
B
5
Posts: 27
Reputation: 277


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Yahoo [Bot] and 4 guests