Camera Pan and Zoom

0 favourites
  • 4 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Hi all, I've built a system for a camera that pans towards the players location and zooms in when you hold the Z key, then zooms out again when the key is released. It works well and does exactly what I need it to. Problem is that its not the most elegant solution and I could do with some tips on how to streamline it and get rid of some of the unnecessary events, variables and sprites.

    https://www.dropbox.com/s/m6v8l3jt48bj5wz/ZoomTest.capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Heya, here is a simplified version I made:

    https://www.dropbox.com/s/u7kyz81qkmu7mu4/ZoomTest_2.0.capx?dl=0

    I removed the need for plugins (couldn't view your capx without them) and some behaviours.

    Using the scroll on your mouse speeds up or slows down the Scroll & Zoom effect (1 variable). Controls are the same.

    Let me know what you think...

  • Y'know what Eindbaas? That is pretty damn slick, and the fact that you've got it down to a single variable, and labeled said single variable as the "Smoothness", wins you points for being one smoooth mother.

    You've added a few more sprite objects, but those paticular type of solid barrier objects are going to be neccasary for my finished product anyway, so that's all good as far as I'm concerned. I will say that I would be interested to see if anyone could do this without any 'camera' sprites at all, but to your credit you only used two (and the replacement for the camera shaking is excellent). This is more than enough "smoothness" for me, and a definitly 'more elegant solution' to the lovely mess that I made. Thank you very much Great stuff X

    Oh... and I'm really sorry about the plugins. I honestly thought I'd deleted any use of those plugins before I uploaded it to Dropbox. I'll check that again tomorrow and re-upload it (not that my original capx will be needed after this, but maybe something in there could be useful to someone for something, as I did try out some interesting crap).

  • Thanks for the kind words Christmas, glad you like it

    The easiest way to stop the player from leaving the boundaries was placing 4 solids around it. I could think of a way to remove the need for the solids and CameraFrame, but that would take me some time at my current skill level. Besides it would only remove the objects and add more code instead, so I went for this approach.

    You could replace the CameraDolly with a hard X/Y position, but that would overcomplicate things when you perhaps want to move the "center-cam" around later.

    Also, I think your screenshake looks better. Granted mine uses only events, but because of the lerping it doesn't look like an uniform screenshake.

    And don't worry about the "lovely mess" you create when trying to work things out. If it works it ain't stoopid, no matter how many events it takes.

    Good luck on your project ;3

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