I am trying to create a Diablo II style skill tree. For the purpose of my initial prototype, what I want to do is have three icons organized on the left pane on the screen. On the right is an empty pane. This pane will be populated with data that is tied to the icon that is clicked on on the right pane. First off, let me explain what I do know. I've taken a look at the following tutorials:
This one taught me how to reference data in a pasted XML file.
This one taught me how to add a .xml file to a project.
Here's what I am trying to do:
-Load a .xml project file on start of layout.
-This .xml file looks something like this:
(EDIT: I've corrected the issues with the XML shown below based on feedback pointing out it was borked)
<?xml version="1.0" encoding="UTF-8"?>
<Keywords>Sword, Long Sword, Technique, Focus Builder, Accurate, Mandatory</Keywords>
<Description>Accurate: +5 Precision. Deals 1*Weapon Damage to target. Builds 1 Focus. If caster has no Focus at time of usage, damage is boosted to 1.5*Weapon Damage.</Description>
<Keywords>Sword, Long Sword, Technique, Focus Consumer, Accurate, Mandatory</Keywords>
<Power>1(W), +.5(W) per Focus</Power>
<Description>Requires at least 1 Focus, consumes all Focus. Accurate: +5 Precision. Deals 1*Weapon Damage (plus .5 Weapon Damage per Focus consumed). Reduces the target's Toughness by 10 (plus 2 per Focus consumed) for 2 rounds. Actionless if user has 3 or more Focus.</Description>
<Keywords>Sword, Long Sword, Technique, Focus Builder, Accurate, Offhand, Actionless, Accurate</Keywords>
<Description>Accurate: +5 Precision. Deals 1*Weapon Damage to target. Builds 2 Focus. Boosts Toughness by 10 (plus Sword Proficiency Level) until end of next round.</Description>
-I would like some way for the action of clicking on a specific sprite, on the left pane, to tell text objects on the right pane to load specific data from one of the three power entries in the .xml file above.
What is the most efficient way to do this? I am struggling with reconciling what I've learned from the first and second tutorial I linked to above.
Thanks in advance,
First of all, your XML contains error. Some characters cannot be used in tag names. Minus and plus signs are a no go, and so are spaces.
Second, you'll have to get familiar with XPath expressions if you want to be able to fetch whatever data you want.
I've prepared a small example for you using your XML data. It displays the description for the selected power. You should be able to build upon it. Happy learning !
Thank you Magistross. At first I was confused what you meant by not being able to use spaces and symbols. But, I get it now. That's only in tag names. I'll play around with your example and I'll re-post if I have questions. Thanks again.
So, I've made a little progress and have been studying up on XPath. However, I haven't had much luck. What I'd like to do is to set text on a text object to be a particular line. For example, if I click on skill box sprite object 1 I want to set a text object to the first power name. So I tried this:
What I end up with is the first word of the power name instead of both of them. What am I doing wrong here?
Another question, once I've resolved the issue where I can pull up the whole name of an entry how do I change the display text in case I want to append text to what I am querying?
For example. I want to pull up the contents of the first Requirements tag, but I want to display it as "Requirements: (contents of the first requirements here)"
Sorry to bump this thread, but I am still hoping to get a response.
Thanks for sharing sample file well I wana to know how to save our file in XML Forment.
Sorry for the late response, you should the "@username" trick so your correspondence know they have a message waiting for them ! <img src="smileys/smiley2.gif" border="0" align="middle" />
The XPath that qualifies the first power's name is actually this : "/rows/row/PowerName"
You should rename your "rows" tag to "powers" and "row" tag to "power", it'd make more sense that way ! <img src="smileys/smiley2.gif" border="0" align="middle" />
Now for your second question, simply set the text to :
"Requirements: " & XML.StringValue("/rows/row/PowerName")
I don't understand what you actually want. Could you explain it a bit more ?
Thanks for asking.
Yes Sure actually I want to save my game in xml format. is this possible in c2........
I have created a game in C2 and and export their file in xml forment
Develop games in your browser. Powerful, performant & highly capable.
And you can't really write xml using the XML plugin, it's only for xml parsing.
You would have to build the xml yourself via events.
Yeah, as Yann said, the XML object cannot be used to create an in-memory XML document... I wonder why too !
But nothing keeps you from writing your own XML string ! You could then output it as a file download using the FileSaver plugin.