Simultaneously/individually scroll frame and drag window?

For questions about using Classic.

Post » Wed May 05, 2010 7:29 am

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:

Source:
Tiny_Crawl_World.cap (41 KB)
B
1
G
2
Posts: 4
Reputation: 633

Post » Wed May 05, 2010 9:40 pm

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?
B
1
G
2
Posts: 4
Reputation: 633

Post » Wed May 05, 2010 9:57 pm

MouseKeyboard.AbsMouseX-Window.X will give you the X position of the mouse relative to the window.
B
79
S
24
G
54
Posts: 4,738
Reputation: 40,739

Post » Wed May 05, 2010 10:36 pm

[quote="R0J0hound":q60wx8eo]MouseKeyboard.AbsMouseX-Window.X will give you the X position of the mouse relative to the window.[/quote:q60wx8eo]

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.
B
1
G
2
Posts: 4
Reputation: 633


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests