Has anyone tried? Cavas Snapshot/CocoonJS

Discussion and feedback on Construct 2

Post » Tue Sep 03, 2013 6:08 pm

Hello all,

I have a game that's basically a paint editor with goals on each stage. I'm working on adding the ability to save your art as a JPG/PNG.

I started by taking a snapshot of the canvas and invoking a download; which worked fine on Android and PC but did not work on my iPhone. I'm not sure if it not working on iOS is a bug or not but I'll investigate later.

To get around the limitation and to deliver the same experience on every platform I started writing a node.js server. The server will accept a POST with the image then it will send it to the provided email. I'm about 2/3 done with it when I realized I'm not sure if CocoonJS supports screenshots! I'll test it once I have time but I figured I ask the community in the meantime.

tl;dr
Has anyone tried using the "Take screenshot of Canvas" action with CocoonJS?

Thanks all!
B
52
S
13
G
7
Posts: 146
Reputation: 6,798

Post » Sun Sep 08, 2013 3:36 am

Hi @basspenguin

I briefly experimented with using the system "Take snapshot of canvas" action with CocoonJS. I actually did have success in sending the snapshot to WebStorage and then using the "Load image from URL" function of a blank sprite object and entering the WebStorage.LocalValue contents. Interestingly, I had to Flip the sprite for it to display properly.

However, I believe there are several obstacles to work around, as I was getting a Javascript exception ('requestAnimationFrame'): texImage2D IllegalArgumentException: Cannot open the given '/private/var/mobile/Applications/blah blah extremely long series of characters that expect represent the JPEG image in WebStorage. Not sure why I get this, as the sprite is deleted when I change layouts and I only get the error when trying to go back to the layout where I originally displayed the sprite.

Anyway, figured I would post and see if any of that is helpful. :) I'm on the latest C2 release, r143, and CJS 1.4.
ImageImageImage
B
38
S
5
G
4
Posts: 79
Reputation: 5,355

Post » Mon Sep 09, 2013 8:46 pm

As a follow up, I do not get a javascript exception when using a Tiled Background instead of a Sprite, however I am unable to flip the tbg to correct the image.
ImageImageImage
B
38
S
5
G
4
Posts: 79
Reputation: 5,355

Post » Sun Sep 07, 2014 3:04 pm

@basspenguin Can you please share code or capx for saving a snapshot in cocoonjs android.
B
12
S
2
Posts: 76
Reputation: 930


Return to Construct 2 General

Who is online

Users browsing this forum: Baidu [Spider], sunisa2532, taker7 and 22 guests