Using LayerToCanvas

0 favourites
  • 3 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hello!

    I've been struggling to wrap my head around LayerToCanvas and CanvasToLayer, how they work and how to use them. I've managed to hunt down a few examples that were both great but I couldn't take much away from them and still don't fundamentally understand how they are supposed to function.

    I have a simple setup in mind:

    1) A sprite spawns an explosion on a standard layer that scrolls rapidly with a 100% parallax rate

    2) The explosion immediately becomes attached to the top layer which has 0% parallax

    The intended outcome should be an explosion that doesn't scroll with the camera.

    If anyone can help with this I'd be very grateful.

  • Say, layer "Game" has 100% parallax, and layer "HUD" 0% parallax.

    Spawn explosion on layer "Game" at (500,200)
    
    explosion Set X to CanvasToLayerX("HUD", LayerToCanvasX("Game", explosion.x, explosion.y), LayerToCanvasY("Game", explosion.x, explosion.y))
    
    explosion Set Y to CanvasToLayerY("HUD", LayerToCanvasX("Game", explosion.x, explosion.y), LayerToCanvasY("Game", explosion.x, explosion.y))
    
    
    Move explosion to layer "HUD"
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you, that worked perfectly!

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