How do I control the sprite animation frames from XML file?

Get help using Construct 2

Post » Fri Feb 19, 2016 6:32 pm

I want to change the frames of a sprite animation or even make changes to it at the end of each paragraph of a XML file. Is it possible?
B
74
S
13
G
3
Posts: 995
Reputation: 7,531

Post » Fri Feb 19, 2016 9:53 pm

It is possible, but quite a bit of a roundabout method. Any particular reason you need to use XML?

Here is a rough idea of the steps:

Import your XML file as a project file. https://www.scirra.com/manual/141/files
Load the XML file into memory with AJAX.request. https://www.scirra.com/manual/107/ajax
Access the data with AJAX.lastdata.
Use tokenat() to parse the information you need from your XML file. https://www.scirra.com/manual/126/system-expressions
Use the information you got to set the Sprite Animation, or to destroy and replace with another Sprite.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Sat Feb 20, 2016 10:02 am

oosyrag wrote:It is possible, but quite a bit of a roundabout method. Any particular reason you need to use XML?

Here is a rough idea of the steps:

Import your XML file as a project file. https://www.scirra.com/manual/141/files
Load the XML file into memory with AJAX.request. https://www.scirra.com/manual/107/ajax
Access the data with AJAX.lastdata.
Use tokenat() to parse the information you need from your XML file. https://www.scirra.com/manual/126/system-expressions
Use the information you got to set the Sprite Animation, or to destroy and replace with another Sprite.


I want to use to set a specific frame in according to the text that is shown, but it seems it takes a lot of work, so, I''try to find another solution. Thanks at all.
B
74
S
13
G
3
Posts: 995
Reputation: 7,531

Post » Sat Feb 20, 2016 10:17 am

Well depending on how you show your text, you could add a simple sprite: set frame action to whatever triggered the text to show - that would be much simpler!
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303


Return to How do I....?

Who is online

Users browsing this forum: bluesun66, Kenthria, Malhog, plinkie, Yahoo [Bot] and 1 guest