How do I load png

Get help using Construct 2

Post » Sat Feb 20, 2016 12:59 am

I just don't get how to load a png. I have spent over an hour and got no where.

What I am really trying to do is click a button that loads a png into a spite (is there a better way?), then type into a text box that sits on the imported picture and then save the picture including the text as a png.

Is this possible?
B
30
S
8
G
8
Posts: 538
Reputation: 7,220

Post » Sat Feb 20, 2016 4:35 am

I think R0J0 answered pretty clearly in the Paster thread, it definitely is possible even without plugins. viewtopic.php?f=153&t=88750&p=1016274#p1016274

Which part exactly are you having trouble with? Do you have a .capx you can upload so we can see what you've gotten so far and help troubleshoot?
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Sat Feb 20, 2016 5:57 am

https://app.box.com/s/2dfh9ub4waycnbrna5pq4z1b8g7yw6zf


The image does not load when I click the button. Can you also show me how to save the image with the text showing in the picture, maybe by clicking a different button?

Thanks
B
30
S
8
G
8
Posts: 538
Reputation: 7,220

Post » Sat Feb 20, 2016 7:20 am

The problem is in your load target.

You did nwjs.AppFolder&"data/mydog.png" , Windows uses \ for directories, so it should be nwjs.AppFolder&"data\mydog.png".

To debug, I recommend adding
Code: Select all
On Layout Start - Set Textbox Text to nwjs.AppFolder&"data\mydog.png"
to make sure you have the exact file path correct.

The saving image is as R0J0 described (with small modification)

On click
--- set viewport size to sprite.width, sprite.height
--- scroll to sprite
--- snapshot canvas as jpeg

On snapshot
--- wait 0
--- browser: invoke download snapshoturl

Make sure your textbox overlaps the sprite or it will get cut off.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Sat Feb 20, 2016 3:05 pm

Just changing the slash
nwjs.AppFolder&"data\mydog.png

Still will not load the picture when I hit the button. I even moved to picture form data to the program folder. Did the program run for you? What am I missing?
I do have the latest NWjs 2/16

Maybe can you do a cap that works and I can see if it runs on my machine? maybe i am missing something small.
B
30
S
8
G
8
Posts: 538
Reputation: 7,220

Post » Sat Feb 20, 2016 5:05 pm

Did you test by exporting or previewing? Make sure the file name/path matches exactly, if you used the debug method I recommended.

This won't work from preview from browser (chrome or other), you have to set the preview to nw.js in project setting.

If you do that you'll see that for preview the file needs to be where you have nwjs installed. Can you confirm your file is there and not the construct folder? (When you export, you'll need to copy it to the export directory)

I'll put together a package capx/exported project for you, but I ran into another issue where textboxes are not captured by the snapshot feature so I'll post it once I put together a workaround for that.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Sat Feb 20, 2016 5:26 pm

https://www.dropbox.com/s/z7fc5hey0yzu5 ... c.zip?dl=0

.capx located in the same folder as nw.exe. Use nw.exe to run exported project.

Again, if you preview from capx using nw.js, you need to copy your file to the nw.js folder.

The issue I found was textbox is not captured by snapshot, so I used a spritefont instead.

There is no confirmation that the download happens in nw.js - check your default chrome save directory.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 0 guests