zoom between two objects

0 favourites
  • 3 posts
From the Asset Store
This is a Dungeon Master tool & the 1st of 12 Combat Engines from the Building Combat Engines for Browser Games workshop
  • Hello friends,

    I can make the screen scroll to a location in the center of two objects, however I need to have the layer zoom out as they move further apart.

    To scroll to center:

    Scroll to position ->

    Obj1.x+(obj2.x-obj1.x)*0.05

    Obj1.y+(obj2.y-obj1.y)*0.05

    Do I need to set an initial variable with the number Distance(obj1,x,obj1.y,obj2.x,obj2.y, then compare that with the current distance clamped so it does not get to small? I think I have the principle, but I am not sure how to do it right...

    Thanks!

  • A bit of a guess here (not really used it much)

    add the "scroll to" behaviour to both your objects - this should keep the screen centred between them.

    setting the scale to the screen height (assuming this is smaller than the screen width) divided by the distance between the two objects should keep them in view.

    You might not want to scale if they are too close so add something like if distance is greater than screen height

    as you said you will also need to make sure the scale doesn't get too small.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I found the plugin Magicam which works perfect, and it was just updated too!

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