turning on / off scroll ratio on the X axis..

For questions about using Classic.

Post » Tue Feb 23, 2016 4:32 pm

Hi all, I have a rather perplexing issue, probably one thats a bit hard to explain

I have my game constantly scrolling, mostly vertical, but it also pans diagonally and on the X axis.. While it does the X panning to create diagonal or horizontal scroll movement, I have been attempting to stop my enemies moving off screen by setting the "flying enemy" layer scroll X ratio to zero, so that while it pans the enemies can stay above you.. that part works fine, I call it "X-locking" for short..

Now the initial lock works fine, but once I have scrolled, say, right for several hundred/thousand pixels, when I want to go back to normal vertical scrolling and release the "x lock" , I switch the "flying enemy layer" back to 100% scrolling and of course they layer just pops back to where it was several thousand pixels ago and everything disappears..

in the manual, it states that layer setting Scroll X / Scroll Y allows you to scroll a layer independently from other layers but I am unsure how this is executed.. It sounds like this is what I want, but have no idea how to control it...

I know that sounds kinda confusing, so to try and summarize , is there any way of forcing a single layer of moving objects to be occasionally locked to the center of the screen (while the enemies move about within it) and be able to switch this lock off, and keep the layer at the point it was released as opposed to leaping back to its origin?

if this is confusing I can try and make a simple cap to demonstrate or annotate a video of an arcade game that does the same..
Posts: 171
Reputation: 2,446

Post » Tue Mar 29, 2016 3:33 am

Maybe try this:

Keep a variable for when it is "locked" called oldPositionX (eg: start position), and a variable for when lock is off called startScrollX (set it only once when it is unlocked! Set to the value of scrollX).

When locking it again, set the position to: oldPositionX + (scrollX - startScrollX), and update oldPosition after locked to the current position.

Or something along those lines.
"Construct 4 lets YOU make advanced games! (but not play them)" Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
Posts: 2,219
Reputation: 19,800

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests