[Solved] ScrollTo behavior works but sprite goes off screen

  • I added the ScrollTo behavior to the Player sprite. So now the screen follows the Player as it moves. Scrolls smooth which looks really good, but the Player moves off the viewable screen before the layers start to scroll. So then you can't see the Player anymore. Is there a way to adjust the camera centering, or something, so the scrolling starts before Players gets off the screen edge?

  • Can you share your capx?

  • The docs say ScrollTo behavior causes the viewport to scroll with and center on the object with ScrollTo behavior. This is definitely not true. Well, partially true, it scrolls with the object but completely looses centering. The object moves faster and leaves the view port behind.

    Is the issue that the ScrollTo behavior does not work with a Physics object moving by applied angular force?

  • When you have two sprites with both scroll to behavior enabled at the same time it wont work. Ensure that you have only one scroll to behavior enabled.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • scrollto does work. It's just very hard to troubleshoot without seeing the problem firsthand.

  • Thank you very much for the replies guys. I definitely do appreciate and need the advice

    I was able to work around the ScrollTo issues. Yes it has issues when you're trying to follow a Physics body sprite. It does not keep the screen centered as the docs say. Perhaps when using simple 8-Dir movement it works, but not with a Physics body. I'm using C2 release r190 (64 bit) as I type this.

    To work around this I created a second "Camera" sprite. Set ScrollTo behavior on this Camera. I then placed the Player sprite in the center and the Camera in the center of the Viewport. Player and Camera both have center origins. The Camera is double the size of the Player. I doubt the Camera size matters, but thought I'd include. On every System tick event, I set the Camera.X/Y to the Player.X/Y * 2. Yes, Player.X/Y times 2. This workaround keeps the Physics body Player sprite perfectly centered on each Viewport X/Y axis as it is forced around. This fixes ScrollTo so it works as it actually should.

    If you've ever used Phaser, it's FollowCamera behavior works perfectly with any kind of sprite. The Construct 2 ScrollTo behavior should also. This being said, Construct 2 is still much easier than using Phaser

  • When you have two sprites with both scroll to behavior enabled at the same time it wont work. Ensure that you have only one scroll to behavior enabled.

    The docs say that you can set ScrollTo on multiple sprites. The Viewport will (will try) to center between the two sprites. I didn't try but I doubt this works.

  • Quick update: I just exported my Construct 2 game to "Android". Opened up the exported folder in "Intel XDK" IDE, built, ran on my Note 3 phone (attached by USB) and it looks and works perfectly! Thank you, thank you, thank you to Scirra and Intel!

  • > When you have two sprites with both scroll to behavior enabled at the same time it wont work. Ensure that you have only one scroll to behavior enabled.

    >

    The docs say that you can set ScrollTo on multiple sprites. The Viewport will (will try) to center between the two sprites. I didn't try but I doubt this works.

    I didn't make myself clear I guess. I meant that It wont work properly because, as you said the camera will try to follow the center between the objects which I believe is not what we usually want.

  • >

    > > When you have two sprites with both scroll to behavior enabled at the same time it wont work. Ensure that you have only one scroll to behavior enabled.

    > >

    >

    > The docs say that you can set ScrollTo on multiple sprites. The Viewport will (will try) to center between the two sprites. I didn't try but I doubt this works.

    >

    I didn't make myself clear I guess. I meant that It wont work properly because, as you said the camera will try to follow the center between the objects which I believe is not what we usually want.

    Ok then yes I agree

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