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

This forum is currently in read-only mode.
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • 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..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

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