does anyknow hopw to make a nice camera effect

0 favourites
  • 2 posts
From the Asset Store
Simple and easily editable template for a dynamic camera that zooms in and out based on how far apart the players are.
  • i woild like to make a camera effect just like in the game tag where it zooms in a out automatically. anybody have the code for this???

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I had no idea what game tag you were referring to. Google linked to a game on the arcade. Looks like the camera centers between the players and zooms so all players are visible at once even when far apart.

    So here's how you'd do it for two sprites. 640,480 is the window size. Find the width and height of the bounding box that contains all the players. You can add to this so there is space around the players. Next you scale the layout. Here it's limited to 1 so it will only zoom out instead of zoom in too. Lastly scroll to the midpoint between the players. For that step you can just give the sprites the scrollto behavior instead.

    w= max(palyer1.x, player2.x)-min(palyer1.x, player2.x)
    h= max(palyer1.y, player2.y)-min(palyer1.y, player2.y)
    set layout scale to max(1, (w/h> 640/480)?640/w:480/h)
    scroll to ((player1.x+player2.x)/2, (player1.y+player2.y)/2)

    For three sprites you can change the calculation to:

    xmin = min(palyer1.x, player2.x, player3.x)
    xmax = max(palyer1.x, player2.x, player3.x)
    ymin = min(palyer1.y, player2.y, player3.y)
    ymax = max(palyer1.y, player2.y, player3.y)
    w= xmax-xmin
    h= ymax-ymin
    set layout scale to max(1, (w/h> 640/480)?640/w:480/h)
    scroll to ((xmin+xmax)/2, (ymin+ymax)/2)
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)