Importin images as URL in a XML or CSV file

Get help using Construct 2

Post » Thu Jun 20, 2013 3:52 pm

Hello everyone,

I'm creating a memory matching game for kids using many different images.
The problem is that I need to randomly pick card images from an online png database and make them appear as cards at startup. Moreover, the file giving the image's URL has to be easily to modify because someone else will update the image databse once i've finished the game.

I've tried to append the image's URL using the AJAX, XML and CSV plugins (and also the URL to Image plugin) but I cant get it to work properly, mainly because importing files with ajax is more complicated than I thought.

What do you guys think about this ?
Should I use AJAX and XML/CSV ? Should I use an array to stock the URL strings ?

I'm quite lost now that I've seen the many tutorials on Scirra and Stack Overflow forums : it seems that there are many methods to use a database-like file in Construct 2 and I dont know wich one would be the more optimized for images (and easy to manage).

Any ideas ?
B
8
S
3
G
2
Posts: 35
Reputation: 2,175

Post » Fri Jun 21, 2013 2:57 pm

I know what happened : the line "standalone" _in the XML was blocking the parsing.

Now I just have to find a way to transfer the data from the XML to an array and to append the urls from the array to a sprite.

That won't be too difficult I hope !
B
8
S
3
G
2
Posts: 35
Reputation: 2,175

Post » Sat Dec 28, 2013 3:10 pm

Hey @Shapter !

How did you get on with this project? I'm trying to do a similar thing. (pulling image's from a database and into a game)
B
15
S
6
G
3
Posts: 87
Reputation: 4,304

Post » Sat Dec 28, 2013 4:27 pm

Hey Necrokrieg,

It worked quite well using the Ajax, Xml and array plugins.

Requested a XML file from dropbox public folder, stored the content of the XML in an array using "for each node" loops (found in the xml plugin) and then loaded images in each objects (cards sprites) usin "for each node" loops once again.

Here's the code :
https://drive.google.com/file/d/0B-727M6ikDE_dmVLazNicFBCOVU/edit?usp=sharing
https://drive.google.com/file/d/0B-727M6ikDE_Nk41T21IazY5TDA/edit?usp=sharing

The URL in ajax is PickedLevelUrl because the previous menu was also importing stuff, so in your case it should be a regular URL.

The only problem was the speed of the wifi while importing the images : I had to build a loading screen and the game wouldnt work if the bandwith was too low ...

I'm no programmer so I dont know if it's a nice and tidy way to do this ! :D

May I ask why are you working on ?Shapter2013-12-28 16:44:15
B
8
S
3
G
2
Posts: 35
Reputation: 2,175

Post » Mon Jan 13, 2014 6:32 pm

oh wow! Good Stuff @Shapter
(Sorry for the late response you didn't notify me with an @)

I'm trying to make a basic 'Look Up' app.
You type in a character's name and their stats will appear along with an image loaded from a URL that's stored in an XML file or CVS spreadsheet.

I like Mortal Kombat BUT always forget the moves so I thought I could type in a character's name to bring up their combos!

Iv made a super primitive version, without XML, etc. Capx
I'm going to go through your event sheet, very helpful!

btw I love your game concept "Agents of a Corporate Empire" It reminds me of Papers Please, love that game. It looks great.
NECROKRIEG2014-01-13 18:34:15
B
15
S
6
G
3
Posts: 87
Reputation: 4,304

Post » Tue Jan 14, 2014 6:28 pm

Hey @Necrokrieg !

Quite a good idea you have there, making an app displaying the moves from a combat game ! It's a good way to keep the players connected to the game even if they're not playing at the moment, like when you play with more than two friends at a time.

The process with loops is quite straightfoward in C2 but be mindful if you want to export as something else than a browser based app : for example CocoonJS doesnt support the XML plugin.

I just saw that we can use crosswalk to keep any browser based features while making kind of an .apk app :
https://www.scirra.com/tutorials/809/how-to-export-to-android-with-crosswalk

I'll look into your capx as soon as I 've dowloaded the new version of C2.

And thanks for Agents of a Corporate Empire ! It's my main project for the moment and I have to confess that Papers Please was one of my main inspiration, with the movie posters from Saul Bass.
B
8
S
3
G
2
Posts: 35
Reputation: 2,175

Post » Tue Jan 14, 2014 7:12 pm

@Shapter ooh thanks for the xml compatibility advice! That's a good idea; releasing a combat app for an established game. It does connect the player more to the game when they can't play. I guess GTA5 did this with their mini game app.
I did another doodle using the CSV plugin instead of using the Xml plugin. It loads images from URLs. The url links are stored in the CSV plugon. Might be useful. Csv Capx


Love a bit of Saul Bass. Check some of this art out. Music & Cover Art



NECROKRIEG2014-01-14 19:13:24
B
15
S
6
G
3
Posts: 87
Reputation: 4,304

Post » Fri Jan 17, 2014 1:20 pm

Now that's my kind of art ! Kind of a weird mix between christian/WH40K/Tim Burton imagery :D

As for the CSV plugin you might want to check if it is compatible with mobile exporters, as it is a third party plugin (made by the community I think).
Also you can import a .CSV file made in excel as a project file from wich you can transfer data to your array (I've never tried it but it seems quite easy).
B
8
S
3
G
2
Posts: 35
Reputation: 2,175

Post » Fri Mar 24, 2017 11:48 pm

Shapter wrote:Hey Necrokrieg,

It worked quite well using the Ajax, Xml and array plugins.

Requested a XML file from dropbox public folder, stored the content of the XML in an array using "for each node" loops (found in the xml plugin) and then loaded images in each objects (cards sprites) usin "for each node" loops once again.

Here's the code :
https://drive.google.com/file/d/0B-727M ... sp=sharing
https://drive.google.com/file/d/0B-727M ... sp=sharing

The URL in ajax is PickedLevelUrl because the previous menu was also importing stuff, so in your case it should be a regular URL.

The only problem was the speed of the wifi while importing the images : I had to build a loading screen and the game wouldnt work if the bandwith was too low ...

I'm no programmer so I dont know if it's a nice and tidy way to do this ! :D

May I ask why are you working on ?Shapter2013-12-28 16:44:15


Hi @shapter, is it possible to re-upload these examples? I am hoping it can help me understand to get images into my xml files / xls files in c2. Thanks,
B
38
S
11
G
1
Posts: 204
Reputation: 4,477


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests