How do I access a local url for an image

Get help using Construct 2

Post » Thu Dec 17, 2015 9:23 am

I want to be able to access an image in a local folder using the load image from URL. I want my user to be able to swap it out by copying a new image to the folder and just renaming to the same name as the last image eg: "Background.jpg" or "myface.png". I had suposed it could be done with "images/Background.jpg " but that doesn't seem to work.

Can anyone help?
B
10
S
2
Posts: 50
Reputation: 1,100

Post » Thu Dec 17, 2015 11:27 am

Would the FileChooser object work for you?
If your vision so exceeds your ability, then look to something closer.
Moderator
B
129
S
29
G
78
Posts: 5,202
Reputation: 54,811

Post » Fri Dec 18, 2015 8:58 am

Thanks zenox98,

So if I were to use FileChooser how do I use that to set the URL of an image loaded into a sprite?
B
10
S
2
Posts: 50
Reputation: 1,100

Post » Fri Dec 18, 2015 10:01 am

If you are talking about the images folder that construct creates after exporting (which contains the images of the sprites etc.): you don't need to change anything in your event system. The swapped image will appear in the game (possibly it could lead to errors, if the swapped in image has the wrong format).

If you are talking about imported files: if you created a subfolder, you load the sprite from URL with: "subfolder/image.png", if not you can just load "image.png".

If you want your users to dynamically store pictures in the game, you could build an editor in your game. A textfield could be used for pasting in urls from images, a file chooser for local images. Load the images to a placeholder sprite and then use the canvas plugin (or paster plugin) to paste the images onto the canvas/paster and save the base64-string of the contents to webstorage (or a database of yours). Everytime your user starts the game, the value will be retreived and loaded into the sprite (if it exists).
Modifying animations will not be practical.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Fri Dec 18, 2015 11:44 am

Thanks mindfaQ I will look into all of these.
B
10
S
2
Posts: 50
Reputation: 1,100

Post » Fri Dec 18, 2015 11:47 am

mindfaQ, I take it Paster plugin is not default with C2?
B
10
S
2
Posts: 50
Reputation: 1,100

Post » Fri Dec 18, 2015 1:28 pm

You stand correct.

plugin-canvas_t64239
plugin-paster_t88750

You can also use the native canvas screenshotting feature of Construct 2 for it (I think), but with it you will have to resize and reposition the screen for the screenshot to the resolution you need the image to have.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Sat Dec 19, 2015 1:58 am

Thanks mindfaQ, That's not really what I had in mind. I want my user to pick one image in a folder. Then have the path to that folder update a bunch of other images.
So if a background image is picked then a bunch of other images img001.jpg, img002.jpg etc all update from the same path.
B
10
S
2
Posts: 50
Reputation: 1,100

Post » Sat Dec 19, 2015 5:32 am

mindfaQ wrote:If you are talking about the images folder that construct creates after exporting (which contains the images of the sprites etc.): you don't need to change anything in your event system. The swapped image will appear in the game (possibly it could lead to errors, if the swapped in image has the wrong format).

If you are talking about imported files: if you created a subfolder, you load the sprite from URL with: "subfolder/image.png", if not you can just load "image.png".




The subfolder method doesn't work for me. Does this need to be on a hosted folder or can it be localhost?
B
10
S
2
Posts: 50
Reputation: 1,100

Post » Tue Dec 22, 2015 2:12 pm

Hmm, looks like construct doesn't create the subfolders physically but instead dumps everything into the same (main) directory.

So one way you could do subfolders would be adding the folder names and files after export to html. But you will probably run into problems with other exporters, where maybe you can't change the file structure.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786


Return to How do I....?

Who is online

Users browsing this forum: CJacobsSA, R0J0hound and 7 guests