Simultaneously/individually scroll frame and drag window?

This forum is currently in read-only mode.
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • I'm working on a miniature sidescrolling project. I want the application window to be drag-moveable while it scrolls, but I'm getting funny behavior out of this.

    My current implementation for scrolling is just like the 'ghost shooter' tutorial: I have a 88x31 game window with a 300x31 layout, and it constantly keeps a horizontally-moving object in the center.

    My current implementation for dragging is that clicking the window sets a value to 1 and records the current mouse location, and as long as the value is set to 1, the window will be moved to its current location plus the difference between the current mouse location and the initial mouse location. When the button is released, the value is set to 0.

    The scrolling works on its own, and the dragging works on its own. But when I have the mouse held down while the game window scrolls, the window inexplicably moves to the right along with the character, while the background of the layout stays almost stationary.

    I'm surely doing something wrong, but I can't figure it out. Can anyone help with this problem?

    Screenshot of events:

    <img src="http://i.imgur.com/nxse3.png">

    Source:

    Tiny_Crawl_World.cap (41 KB)

  • UPDATE:

    Playing around with the debugging frame, it looks like I've figured out the source of the problem: MouseX and MouseY are relative to the mouse position in the LAYOUT, not the mouse position in the WINDOW. Thusly, whenever the screen is scrolling to the right, MouseX is continuously increasing while the mouse is stationary.

    So, my question has changed:

    Does anyone know of a way to retrieve the mouse pointer location in terms of the window, instead of in terms of the layout?

  • MouseKeyboard.AbsMouseX-Window.X will give you the X position of the mouse relative to the window.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • MouseKeyboard.AbsMouseX-Window.X will give you the X position of the mouse relative to the window.

    Great, thanks! I realized after posting that it would probably be some algebraic logic to do it, but I was having trouble getting my head around it.

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