How do I set layer zoom relative to objects coordinates.

0 favourites
  • 13 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Hey there, i'm trying to make a dynamic zooming camera for a 4 player game. (it's an arena/stadium type game)

    The idea is that the camera is always framing the 4 players with an acceptable margin. So if the players are near each other the layer zooms in, if the players are far apart, they layer zooms out.

    If we could do this without the camera going outside the layout it would be great.

    I've been trying to do this for a while now, but I haven't been able to produce any proper results yet. My best effort so far was to "pick the distance from the player who was farthest from the camera coordinates", and use that to manually set the zoom values on a cosp formula using lower and higher zoom values, but it's crap and doesn't work like it should, though sometimes it looks like it's going to Dx

    i searched around the forums, and saw a couple post where they where using the distances of the players, compared to the window's size, but i wasn't able to make that work either. I'm assuming i'm really not good at scaling the damn layers (i need to scale only a couple of layers, and not all of them in the layout)...

    anyway, any help would be really appreciated T_T

  • Have you tried giving each of the players the scroll to behavior ?

  • lennaert thanks, but that's really not what I need. I'm looking for a way to dynamically zoom in and out with the character change their distances to each other, the scroll to behavior has nothing to do with that, it's used to tell the game where to center the camera. thanks anyway =)

  • Your question is almost the same as the one in this thread from yesterday, it might help:

  • lennaert thanks, but that's really not what I need. I'm looking for a way to dynamically zoom in and out with the character change their distances to each other, the scroll to behavior has nothing to do with that, it's used to tell the game where to center the camera. thanks anyway =)

    edit: sorry, you meant relative .. misread some, my approach with all objects with scroll would center the camera automatically in their midst

  • LittleStain as a matter of fact, I had studied those post extensively, but they don't work the way i need to. In my game there can be 2 to 4 players and I haven't found a way to adapt those examples to my current needs =(

  • It shouldn't be hard..

    The explanation is there to get the x-coordinates and y-coordinates to use in the zoom example from the referenced thread..

    In that example x and y of player1 are used and x and y of player2

    instead of using them you use the lowestx,lowestY and Highestx,highestY

    if there are two players, three players or four players shouldn't make a difference..

  • LittleStain if it wasn't hard, or if I was able to, i wouldn't be asking for help =(

    Do you know how to apply the logic to what I need? could you help me please?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • LittleStain if it wasn't hard, or if I was able to, i wouldn't be asking for help =(

    Do you know how to apply the logic to what I need? could you help me please?

    You should apply it like I explained above, but if I have time I will adjust the capx for you..

  • Sorry it took so long to adjust the capx, I should have been able to do it within 10 minutes..

    https://dl.dropboxusercontent.com/u/485 ... ayers.capx

    I know it isn't perfect, yet..

  • Sorry it took so long to adjust the capx, I should have been able to do it within 10 minutes..

    https://dl.dropboxusercontent.com/u/485 ... ayers.capx

    I know it isn't perfect, yet..

    oohhh, I tinkered with something alike yesterday, but stopped after an hour ... (weird stuttering)

    Nice one

    *steals*

  • LittleStain ok, now that i've seen it done, i have to admit it's really damn simple =/, but it's a lot more "math minded" than i'm used to. I send you a tasty digital cookie with all my appreciation! your solution is amazing.

    Thanks for helping me ^^!!

  • LittleStain ok, now that i've seen it done, i have to admit it's really damn simple =/, but it's a lot more "math minded" than i'm used to. I send you a tasty digital cookie with all my appreciation! your solution is amazing.

    Thanks for helping me ^^!!

    Luckily I didn't have to make up the math part..

    I'm terrible at it..

    thanks for the cookie!

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