Change Image From Url on a different Layout

Get help using Construct 2

Post » Tue Mar 12, 2013 12:13 pm

Hello Guys,

in my loading screen, I load the data of a Player. After that I want to change Sprites wit LoadImageFromUrl. This Sprites are on a different Layout and cause of that I cant change them....

Changing Images on the same Layout is no problem.

I could load them on the right Layout but this is not what I want. I want that the Player loads one time his data and his items.

Because many Objects have over 20 styles it is also not nice to give them a animation frame and set the step to his style.

Is there any way to do that ?

Thanks ;)
B
15
S
6
G
6
Posts: 512
Reputation: 5,550

Post » Tue Mar 12, 2013 6:52 pm

Yes, I had a similar delima recently. What I did was create a dictionary to store the values that I wanted set in the other layouts. The dictionary content also became the foundation of my save system. JSON is pretty simple to understand.

1. Create a dictionary object (this is a global object)
2. Create what I call a "validate button"
-Create text box called validate
-Create event "On left click of object 'textbox validate' download DictionaryasJSON AND set textbox value to DictionaryasJSON
3. Launch your game and click on the 'validate' object and download the JSON file. This will provide you with a template for adding values by hand instead of having to push them all initially.
4. Find the JSON file and put in all your keys and values (you will need to set it to open with notepad)
5. Save the JSON notepad text file and in construct2 right click on the "Files" folder on the project list typically on the right hand side and select "Import files" then select the JSON file you just modified. (from now on you can doubleclick the JSON file in the project to modify it and blow the other one away.
6. Set your "on layout load" to set the dictionary to the contents of the JSON file (this is to initially populate it, these values will remain as long as the game is running as it is stored in RAM)
7. Now you can use the Dictionary Set key and Dictionary.Get to call upon values like to set and start the name of an animation stored in it.

Let me know if I need to be a little more clear and I will capx it for you.Alexixiv2013-03-12 18:52:32
B
6
S
3
G
1
Posts: 102
Reputation: 1,379

Post » Wed Mar 13, 2013 8:03 am

Wow thats much big thanks, a capx would be amazing.


I think I got it, but my problem is that the user need to load on every Layout again some seconds the right images, and that is not what I want. I want that he just needs to download all the files once.

localboss2013-03-13 08:11:03
B
15
S
6
G
6
Posts: 512
Reputation: 5,550

Post » Thu Mar 14, 2013 9:17 am

Push question ist still open
B
15
S
6
G
6
Posts: 512
Reputation: 5,550

Post » Fri Mar 15, 2013 8:52 am

Really nobody got this problem before ?
B
15
S
6
G
6
Posts: 512
Reputation: 5,550

Post » Mon Mar 18, 2013 10:45 am

Last Push, if no one answers I surrender and let the users load on every single layout.
B
15
S
6
G
6
Posts: 512
Reputation: 5,550

Post » Tue Mar 26, 2013 6:28 pm

I will put a capx together
will take me a little while to strip it down so that only this function exists
B
6
S
3
G
1
Posts: 102
Reputation: 1,379

Post » Tue Mar 26, 2013 8:13 pm

Ok here is the capx I put together showing Dictionaries and JSON:
https://docs.google.com/file/d/0B4hvjRyB7pvBZEUtdUhvX3ZLVkU/edit?usp=sharing

The dictionary can be used to store the names of animation names as a globally accessed value.

Hope this helps
B
6
S
3
G
1
Posts: 102
Reputation: 1,379

Post » Wed Mar 27, 2013 9:33 am

Thanks for this awesome .capx, but I have a different problem. I need to load on Layout 1 all images, this means also custoum player specific images that are placed on e.g Layout 7. With your .capx I can load the ImageUrls and load the Images, than the player is on Layout 7. But this also means he needs to wait again some seconds to load the right files.
B
15
S
6
G
6
Posts: 512
Reputation: 5,550


Return to How do I....?

Who is online

Users browsing this forum: BipolarMike, totoe and 24 guests