How do I zoom gracefully.

0 favourites
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • I've got a simple set up with a zoom variable. Set the layout scale to the value. Use up arrow to zoom in and down to zoom out. The problem is the best zooming is in. You seem to have to set the zoom scale to 1 in order to get the zoom to lerp to normal. The problem is this allows for no zoom out. I guess when the value of scale layout hits zero some other internal calculations get fishy.

    What's the most graceful way to zoom below zero, and get back to 1 when zooming out?

    Thanks for any advice offered

  • I'm not too sure about zooming with lerp cause I've never used it. What I used in the past was just set layoutscale - 0.5*dt and the opposite to zoom in and out. It was smooth and worked well enough for me.

  • Hey, thanks for the post. It's not working though.

    Key arrow up - set layout scale to 0.05 * dt

    Key arrow down - set layout scale to -0.05 * dt

    When I press up the sprite just vanishes. Do you think you could post a capx, or anyone else? I can't post mine because of low reputation.

  • I'm totally new to C2, but do have some programming experience. This is what I did for zoom in my game.

  • This is the thing though. Your min zoom is 1. That means you're only going to be able to zoom in and then zoom out to normal zoom. This works for me too. But I'm not trying to focus on zoom in.. I really want a zoom out. Like what you would do if you were playing and rts and wanted to see more of the map..

    When I zoom lower than 0 and zoom back in the objects are not where they started. It never zooms back to 1 properly after going below zero

  • The weird thing is, I'm watching a YouTube video where the person sets the layout scale to 0.5 and zooms in again by setting the layout scale again, and it works great. Simple. I do the same thing and it does not work the same. There are no errors. When the scale is zoomed out below 0 and back in again everything is shifted up and to the left, and the zoom is not normal, and sprites are not where they started.

  • As a test I tried setting my min zoom to 0.00001 and it lets me zoom out to the point where I can't even see my game anymore. When I zoom back in its fine.

  • Okay, I must have a bug. I'll check around. I'm going to update Construct to the latest version, and see if that was the problem.

  • This is a really simple zoom I did.....I mean really really simple

    You mean when you zoom back, objects seem to be at slightly different locations from where they originally were? Sounds like you are not using a "scroll to", so your camera doesn't know where to focus to. Look at the capx above and you should be able to understand that part.

  • Scroll to isn't a possibility. There are going to be selectable units on the map not a single character. The tutorial I just watched worked fine on YouTube. I just downloaded the latest version of Construct 2 and bought a personal license. I have no idea why this isn't working right.

    I'm gonna check out your file though Thanks for taking the time. If this doesn't fix I may need to try to get a video of the problem up..

  • There must be one little thing I'm doing wrong. Even when I copy and paste your events to my file it doesn't work the same. Have you set anything besides the events? Is there something special set in the game window, in the layers? What is Var1 set to?

  • It must the scroll to object! lol, like you said. I'm going to have to mess around with attaching a blank sprite to the selected unit. That way when the player zooms out it will zoom in on that player. Sorry I didn't understand what was going on here.

    So, just wondering. When I set up mouse to drag the map, or mouse drag scroll, based on another tutorial, will this work differently? Can I set scroll to, to the mouse? or something?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ugh, Now I'm having trouble with scroll to, and the mouse in general. Setting the cursor from sprite does not work, in any browser, or if I export the game for window.

    Start of layout - set mouse style to none.

    Every tick - set cursor from sprite.

    does nothing. The only thing that worked is.

    Everytick set cursor style - none

    every tick set position of cursorSprite to MouseX, Mouse,Y.

    The problem is when the cursor is used to scroll the screen it scrolls really, really fast.

    If I try to delay the speed by doing this.

    every tick - set angle of cursorSprite to Mouse.X, Mouse.Y and cursorSprite move forward 2px

    I get the slow scrolling I want, but sometimes the sprite image flips out and spins, which is no good.

    Construct is very buggy when it comes to the mouse. I already know it doesn't work in EI.. but you might as well add Chrome, and Firefox to the list, because they aren't working there either, or in desktop export...


    Also wondering, is there a way to set the scroll speed, mouse speed, anything?

    I could handle the first working method, set sprite to mouse position, but can't handle the speed the screen scrolls when using the mouse to scroll...

    This is horrid experience for paying customer

  • You can't scale to 0, because at 0 it would get infinitely small. Below 0 it would probably turn around the screen axis, but let's just assume, that the values cut off at 0, so that won't happen either.

  • I see, thanks for the info. I'm not sure how low the numbers are going now, but they must be quite small. Able to get the sprites to be tiny in the top left corner. This is working now, but the newest issue is the mouse pointer. No matter what events I set up it doesn't seem to work.. The closest thing to what I wanted fro slow scrolling was

    set mouse style to none.

    every tick set sprite to point at Mouse.X,Mouse.Y and move the sprite forward 2px.

    Also the spirte for the pointer is set to scroll to.

    This lets me move the mouse around the map scrolling slow, but sometimes when the mouse is still the pointer spite I have flips out. It has something to do with the angle, and continually moving forward. Is there a way to capture if the mouse is moving? This might be a method of stopping it from flipping out.

    Something like

    If mouse is still set pointer sprite to Mouse.X, Mouse.Y...

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