How can I Snap the screen (PrtScn)

Get help using Construct 2

Post » Sun Feb 19, 2012 7:09 pm

hey
i want to add to my game an option that the player will be able to snap the screen of the game and share it on facebook by pushing a button or even download it as a pic file
someone know how can i do it??
B
23
S
5
G
4
Posts: 48
Reputation: 5,197

Post » Sun Feb 19, 2012 9:27 pm

The bad thing is that Javascript can't access the Clipboard (where the PrintScreen is sotred), because of security restriction.
So you need to have a plugin to render your layout to a PNG (for example the Canvas plugin from R0J0hound), and send that PNG.
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Sun Feb 19, 2012 9:32 pm

Could paste all your game into a canvas object (see plugins). (that's for the snap part)

For the sharing part you need a way to send image data in an ajax query. But as the default Ajax object use Get method I don't think you have enough room to send any screen size image.
There's an Ajax plugin that use POST method somewhere in the plugin list but you still need a way to convert your canvas into image data and probably a php page to interprete it.
And remember. I can be totally wrong with the sharing part but for the snap part that's how I would do it.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Feb 20, 2012 6:09 am

It should be possible by a plugin actually - a plugin could call toDataURL() on the main canvas and download a PNG of whatever the canvas is showing. You may not be able to copy it to the clipboard, but you could download it or upload it somewhere else.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Mon Feb 20, 2012 10:03 am

thanks
helps a lot!!
B
23
S
5
G
4
Posts: 48
Reputation: 5,197


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests