Setting Up Screen Capture
MessiahStudios

Scenario: Player gets a score and wishes to take a screen shot and share it on the provided social media links within the game.

 

Is it possible or should I look for another method to share their highest or best score?

All 5 Comments
Gio

Hi

Using wade.screenCapture you can save what is currently on the screen to an image.

Using wade.getImageDataURL you can then get this image as a Data URL.

You can do what you like with this data url, depending on how your social media API works you might be able to upload it directly or embed it in a post.

wade.screenCapture('myScreenCapture', function()
{
    var imageData = wade.getImageDataURL('myScreenCapture');
});

 

 

foxcode

Hi MessiahStudios

I've not done this before, but I think you can do it using wade.drawLayerToImage

You would have to call it for each layer, drawing to the same image each time to "build" a screenshot.

It's a while since I've messed with share on social media, but if they accept an image, you could probably call wade.getImageDataURL on the image and pass that.

I will have a go at getting a screenshot that includes all the layers myself and report back

EDIT: Follow Gio's advice, I missed screenCapture when looking at the documentation. Second. Gio, you are meant to be on holiday :p

MessiahStudios

Let's say Facebook is the target platform.

MessiahStudios

I'm still learning JavaScript...

Let's say I make an image that says "screenshot" and it's a .png file type.

 

Would the code be similar to this?

var screenShotSprite = new Sprite('images/screenShot.png', wade.app.layers.front);
var screenShot = new SceneObject(screenShotSprite);
screenShot.onMouseUp = function()
{
    wade.screenCapture('myScreenCapture', function()
    {
        var imageData = wade.getImageDataURL('myScreenCapture')
    });
};

 

Gio

That looks correct to me. Does it work for you?

Post a reply
Add Attachment
Submit Reply
Login to Reply