Canvas Snapshot - LayerToCanvas and DevicePixelRatio

0 favourites
  • 4 posts
From the Asset Store
Pixel Destruction like in "Worms" (Drawing Canvas based)
  • Hi, I am trying to take a canvas snapshot (not drawing canvas) of a particular area (in this case a sprite (Sprite2)) and I cannot work out why its not working using the events as shown in the photo. To be honest, I've been down this road before and gave up, apparently it is possible, why it has to be made so difficult I'm not sure.

    The following works only if the window/browser/viewport is exactly the right size to the layout. Otherwise, it appears the Offset works (X,Y) but the Width and Height are still incorrect.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have finally figured this out so posting the answer for future users (including myself!). From my initial test this will snapshot the area of "Sprite2" regardless of screen size ETC.

    I still this there could easily be another function added to the likes of "Take snapshot of area" and it does all this for you?

  • Here is my version:

    | Global number r‎ = 0
    + On Space Key pressed
    -> System: Set r to PlatformInfo.CanvasDeviceWidth÷ViewportWidth(0)
    -> System: Take snapshot of canvas (PNG, quality 75, offset Sprite.X*r, Sprite.Y*r size Sprite.Width*r x Sprite.Height*r)
    
    
  • I have finally figured this out so posting the answer for future users (including myself!). From my initial test this will snapshot the area of "Sprite2" regardless of screen size ETC.

    I still this there could easily be another function added to the likes of "Take snapshot of area" and it does all this for you?

    Thank you so much for your post, you saved my App!

    Geribi

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