How do I create a database with picture and text, and...

Get help using Construct 2

Post » Thu Aug 11, 2016 9:03 am

Hello.


Im on construct 2 since 2 month, and i have one questions.


Its possible to create a database with picture and text, and display random on the screen ??

For example :

Image

IN THE SQUARE ITS A RANDOM IMAGE IN DATABASE

Thanks in advance
B
5
Posts: 8
Reputation: 241

Post » Thu Aug 11, 2016 9:51 am

Yes it is possible. It depends which platform you are developing for, as to the best way to do something like this.

If you are making the project for PC, then you can use NWjs and simply pick files from a folder at random to display - whether they're text or pictures.

If you are making this for mobile then you can use other methods, like loading the images from a URL perhaps - of it your images are embedded in the project you can just make them all in one sprite object as animation frames, then set the animation frames randomly.

IT also depends what you mean by "database". The way data structure is typically/easily done in Construct 2 is via JSON, but you can do any way you like depending on your ability. I have made database structure will token delimited plain text, as well as JSON, as well as nested dictionary JSON. It really just depends how you want to make it work :)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Sat Aug 13, 2016 7:31 am

Oh nice, thanks your for your hellping !
B
5
Posts: 8
Reputation: 241

Post » Sat Aug 13, 2016 2:26 pm

SoldjahBoy wrote: I have made database structure will token delimited plain text, as well as JSON, as well as nested dictionary JSON. It really just depends how you want to make it work :)

~Sol


Could you please show/tell how you used JSON within C2? Is there a plugin or something? I am currently storing my level up information in XML, which worked fine on XDK exported games. But when I switched to CocconIO , it doesnt seem to support XML at al :(
Create your own Isometric Runner Game using C2:

Image

Check out my game "Last of the Survivors":
Play Store
App Store
B
60
S
14
G
2
Posts: 427
Reputation: 5,564

Post » Sun Aug 14, 2016 3:03 am

@SamRock I used nwjs for this. I believe webstorage/localstorage can also do the same. Just set a global variable to your json string and use it as an expression in your save/load structure :)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Sun Aug 14, 2016 10:10 am

SoldjahBoy wrote:@SamRock I used nwjs for this. I believe webstorage/localstorage can also do the same. Just set a global variable to your json string and use it as an expression in your save/load structure :)

~Sol


Sorry bit weak on the JSON part. Would really appreciate if you could share some sample code :)
Create your own Isometric Runner Game using C2:

Image

Check out my game "Last of the Survivors":
Play Store
App Store
B
60
S
14
G
2
Posts: 427
Reputation: 5,564

Post » Sun Aug 14, 2016 11:29 am

THIS TUTORIAL may help.

Getting a JSON string from an array or dictionary is an object expression used in the action portion of your event. You will typically want to save or load values for an object, or paths to things... JSON data is specific to these objects, but your use of it isn't limited. You can store any information from any object you wish (however you want to define it) and export the data from the array or dictionary as JSON. You then use NWjs or localstorage depending on your target platform to save the JSON string as a file.

In your original question you want to have random images appear and some random text... it's up to you how you define how those work. You can have NWjs count the number of files in the directory, and use a random number in that range to show your image. You will need to come up with a naming structure or other means of easily recalling your images (eg. image01, image02, image03; etc)

Your text could be stored in a single dictionary, and even your folder path to images (or however you're thinking of doing it).

I can't really provide you with an example because you still haven't mentioned which release platform you are wanting to use. It would help if I knew if it was for PC or mobile device/website. I know a lot more about using NWjs (PC) than I do about localstorage.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests