How do I zoom in without changing layout size/coordinates?

0 favourites
  • 6 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • I have a game where you point and click and an object moves to it (using a target object for my player character to move to using bullet behaviour. Player stops when it hits target until the next click is made).

    I also want to have a zoom function to gradually zoom in on the player when certain parameters are met.

    I've got both of the above working, but the only problem is that I'm finding that parts of the layout become inaccessible.

    i.e. when zoom on the layer is up to 1.5 or so, I can't get my player character to move to the top left of the layout - it's become inaccessible.

    ScrollTo behaviour is being used on the player to control the camera.

    Until I tried doing the zoom effect ,everything was working fine.

    Does anyone have ideas on how to solve this?

    Thanks for your time in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Unbounded scrolling

    By default the game window cannot scroll past the edges of the layout. Set this to Yes to allow unlimited scrolling in any direction, even past the edges of the layout.

    https://www.scirra.com/manual/67/layouts

  • Thanks for helping out granpa

    Then the problem now is that I can see loads of empty space beyond where I couldn't before, when I'm unzoomed!

    2 solutions to this I suppose:

    1) Just put big dark blocks there to symbolise the boundaries of the game area.

    2) Change unbounded scolling on the fly if that's possible.

    What do you think?

    What does anyone else think?

  • Scroll to position

    Scroll to X

    Scroll to Y

    Set the X and Y positions to center the view on. This scrolls all layers taking in to account their parallax property.

    clamp(x, lower, upper)

    Return lower if x is less than lower, upper if x is greater than upper, else return x.

    scroll to clamp(player.x,whatever,whatever)

    scroll to clamp(player.y,whatever,whatever)

    Play with this , might work .

  • Not sure that I understand what you've written there entirely

    Thanks for your help, but could you explain a little bit more or elaborate on what you've written above?

  • You found out what unbounded scrolling does so now you control it manually. The scroll to x and scroll to y let you do just that ! By using the clamp() with your player x and y along with the scroll to action's your saying scroll to player x or y unless the player gets beyond a point where you don't want to scroll any more , otherwise you see the areas that you rather not see anymore . The first parameter of the clamp will be the player's x or y position , the next parameter the minimum position left or top of your layout and the last parameter the max position of your right or bottom of your layout respectively . This way it scrolls with your player like normally and stops scrolling when the player get's beyond that point where it normally would have stopped if unbounded scrolling was turned off , this is usually the halfway point of your view port . So if you have a bigger layout that your view port you will have to input the parameters in the clamp () comparator after figuring them out .

    Hope i did not lose you ,if someone can explain it better then please do !

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