XML for complete noobs?

Get help using Construct 2

Post » Thu Mar 14, 2013 10:24 pm

B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Thu Mar 14, 2013 10:32 pm

Thanks @cincipon , I guess I'll just have to play around with it a bit.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Thu Mar 14, 2013 10:34 pm

AJAX is used to get a xml file in wherever.

Didn't you see a xml file in files folder? it's very easy and it's weird anyone couldn't understand my .capx

Try to run preview, then open aj.xml in C2, change the numbers to balls and speed whatever you want, then try to refresh browser (do not click preview again in C2) you will understand.

It would work with levels if you try to experiment. Dictionary is just a database of values.

It's designed to update the game WITHOUT editing in C2. Especially for anyone who don't have C2 can edit the game.

I made a post to you according to this thread title "XML for complete noobs" my .capx will explain you how XML works.

Sincerely, if you really want to learn how to use XML, then the result is your ignorance seems rude, i wouldn't to help you again.
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Thu Mar 14, 2013 11:11 pm

@joannesalfa

I sincerely apologize - I just downloaded your capx again and realized what it did. The first time I looked at it I didn't notice the XML file and I was put off by the AJAX as I thought it involved web connectivity, etc. I was also put off by the red balls - when I ran it I thought they were in rows and I didn't see what they meant. Again, my fault for not looking into it enough at the time.

Thanks so much for your help mate, now that I know a little what I'm doing it helps a lot.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Thu Mar 14, 2013 11:32 pm

Thanks for your consideration!

AJAX is called "Asynchronous JavaScript and XML" It can relate to XML where to get the values from any place.

I would explain you again in different way...

This .capx is basic one how to use XML, if you see:

<ball category="RED">

<count>4</count>
<speed>200</speed>

</ball>

Ball Category RED, i didn't implement an event to pick "Category", it's an idea where to pick an object.

Count is 4, it means it could spawn 4 balls, if you change 4 to 10, it will spawn 10 balls.

Speed is 200, it's currently bullet speed for red balls.


If in case AJAX fails, you can add extra events to default values.


I hope you master XML.
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Fri Mar 15, 2013 12:06 am

Thanks again!
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri Mar 15, 2013 1:34 am

Is this method supported by CocoonJS? I think with the last update they added support for this (Full native XmlHttpRequest (AJAX) support.) but I'm not sure.Xavier2013-03-15 01:34:59
B
63
S
23
G
17
Posts: 254
Reputation: 14,342

Post » Fri Mar 15, 2013 1:59 am

So there a few factors to consider here. You mention you would like to store things such as level name, level number and "game specific stuff". What sort of game specific stuff are you thinking? If you are planning on structuring your levels through XML files and then load them up on a per-level basis, it might be more tricky than it seems (eg. Saying this level has these 3 enemies of type B is pretty hard to convert into an actual object in C2). However storing things like level introduction text, random AI sentences etc. would be a good fit. So I'm curious what sort of information you would like to store?

Some other things to consider - XML can be a pain to manage. If you are just storing simple shallow data like this Microsoft book example it's not too bad - You can manage that with notepad++. But if you are planning on having deep nodes in your XML files like this slightly more complex example it can quickly spiral out of control. Also remember that any structural changes to the XML might render entire blocks of code in C2 unusable.

If you can post anything you can think of that you would like to be stored in XML, what problems you are hoping it will fix (that you can't do right now) and how you would like to use it game, I bet we could come up with some good examples how to structure your xml, some real-world examples to teach XML, and check if what your hoping to use XML for is appropriate.
boolean2013-03-15 02:02:00
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Fri Mar 15, 2013 3:18 am

[QUOTE=Xavier] Is this method supported by CocoonJS? I think with the last update they added support for this (Full native XmlHttpRequest (AJAX) support.) but I'm not sure.[/QUOTE]

@Xavier Yes AJAX it's supported on CocoonJS :)

Make sure to set CORS (Cross-Domain Control)to hosted files before to get them in CocoonJS launcher.

Unfortunately, CocoonJS doesn't support XML object.

B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Fri Mar 15, 2013 10:23 am

@boolean Oh don't worry, I'm only planning on storing simple stuff as you said. Game-specific stuff would be like 'number of clouds', zoom scale, etc. So I assume XML should be fine for this.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests