How do I send a drawing canvas snapshop via multiplayer?

0 favourites
  • 3 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • I want to

    1. host creates a picture on drawing Canvas, then sends drawingCanvas.asJSON data to peer via multiplayer message

    3. peer recieves message and sets drawingCanvas picture/image from asJSON and is able to "see" the picture created by the host.

    Is that possible?

    I've tried it, but the peer's drawing canvas doesn't load any data

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Canvas.AsJSON doesn't contain pixel data. You need to copy all pixel data into an array and send that array as JSON. You can use a bit of scripting to make this much faster:

    	var c = runtime.objects.DrawingCanvas.getFirstInstance();
    	c.getImagePixelData().then(d=> {
    	runtime.globalVars.canvasAsJSON = JSON.stringify(d.data);
    	})
    

    Note, that to load this data back into Drawing Canvas on a remote machine, the canvas needs to be exactly the same size and resolution.

    There may be a more efficient way to do it with BinaryData plugin, but I don't know it.

    And either way, sending a picture will use a lot of bandwidth and cause a massive lag, unless it's a very small picture.

  • Thanks for the reply.

    I've done just as you suggested.

    The problem is, when peer receives it, their canvas enlarges off screen.

    How do I adjust the resolution?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)