0 Favourites

Zoom Problem (.cap added)

This forum is currently in read-only mode.
  • In my level editor, you can zoom in or out. There's a cursor that follows the mouse in a snap-to fashion, and a panel on the side of the editor to select a tile from a tileset.

    Problem is, when the zoom is greater than 100 the cursor is no longer positioned correctly; it's offset to the lower left, preventing me from selecting the correct tile when zoomed in.

    How can I fix this?

  • Anyone? I can post a .cap if needed..

  • Sounds like your trying to go past what bounded scrolling will allow.

    To test tick unbounded scrolling in preferences.

  • Unbounded scrolling is already checked.

    I should have mentioned this in the first post: The layer the tileset is on has a zoomX/Y rate of 0% so you can zoom in on the map editor part (the grid) without affecting the tileset and menus. That's what's causing the problem. I think I just need to add something to the event that sets the cursor position to the mouse, so that it changes with the zoom %, but I'm not sure what.

  • Well without seeing how your doing the snap, I'd say the zoom should modify the snap by a percent.

    So if your snap was 25 with a zoom of 100 % it would be more like 50.

  • I also have a similar problem. When I use a zoom, all my HUD layers (the ones with Scroll X/Y Rates = 0%) will get positioned wrong

  • Well without seeing how your doing the snap, I'd say the zoom should modify the snap by a percent.

    So if your snap was 25 with a zoom of 100 % it would be more like 50.

    Exactly! I'm just not entirely sure how to put that into the expression. I've messed around with it but no luck. The cursor snaps to the mouse like so:

    Cursor.x = int(MouseX/8)*8

    Cursor.y = int(MouseY/8)*8

    8x8 tiles, of course. Zoom goes by the hundreds, 100%, 200%, 300%, etc.

  • I haven't tested it, but from my head:

    If zooming in to 200%, the area (virtually) represents double the size. Theoretically

    Cursor.x = int(MouseX * (Zoom/100)/8) * 8

    should work.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I haven't tested it, but from my head:

    If zooming in to 200%, the area (virtually) represents double the size. Theoretically

    Cursor.x = int(MouseX * (Zoom/100)/8) * 8

    should work.

    Damn. Sounds like it would work, but it doesn't. I'll upload a .cap soon, might make things a bit easier. I really need to figure this out :T

  • Here's a .cap I quickly put together to demonstrate the problem: Download Here

    The white cursor is for placing tiles, and is on the layer that zooms. The red cursor is for selecting tiles, and is on the layer that doesn't zoom.

    Use the mouse wheel to zoom in or out.

    Notice how the red cursor becomes offset when zoomed in. (The mouse has to be over the panel on the right to see this)

  • mediafire.com

    Does this work for you?

    Well, it keeps the tile cursor from getting offset when zooming, but now the map editor cursor becomes offset :T

    That said, I can now select the correct tile when zoomed in, but can't place it in the correct spot.

    I'm starting to wonder if the zoom is just broken..

  • No, it isn't. It's just that the zooming takes place centered, and (at least I) didn't take that into account.

    + MouseKeyboard: Mouse is over Box
    -> Cursor_MapEditor2: Set position to int((116 - ((ScrollXRight - MouseX) * (ZoomX / 100))) / 8) * 8 + Box.Left, int((480 - ((ScrollYBottom - MouseY) * (ZoomY / 100))) / 8) * 8 + Box.Top[/code:37rfkk1v]
    
    This works. The visible width of the box is 116, although the total width is 120. If you change the position or size of the box, you need to adjust this value, too. And of course the same has to be done to the (visible) height value 480.
    
    EDIT: It works on the original cap you posted (Just wanted to make sure about it  )
  • Aha! Works perfectly. Thanks

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