Change location of Player in Scroll To Behavior

0 favourites
  • 6 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Hello everyone,

    Using the Scroll To behavior, the player will remain in the middle as long as it is not near the edges. But is there a way to change the location of the player when using this behavior? The player will be on auto movement, so I would like the player to be more to the left than the center.

    I open the example autorunner, but it used a different method, and I am afraid it might not work for my game because of how certain objects in my game function.

    Would really appreciate any help. Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I haven't tried this, but maybe create an invisible sprite. You then give this sprite the ScrollTo behaviour. Then every tick set sprite position to Player.X+Your_Value and Player.Y. But it is hard to advice about, without knowing more about your game.

    Cheers,

    thegrind

  • That's brilliant!!! Thanks I never thought about it that way!! I will give it a try! Will have to think of a way to handle it need the edge of the screen, but should be doable. Again, thanks a whole bunch!!! <img src="smileys/smiley20.gif" border="0" align="middle" />

  • I second the use of an invisible sprite as a pseudo camera. This gives you even more options including a smoothly-scrolling camera to make your game look silkier! Instead of Set position to Player.X, use lerp.

    Every Tick: Set Position to lerp(Camerasprite.X, Player.X+200, 7*dt), lerp(Camerasprite.Y, Player.Y, 7*dt)

    This opens it up quite a bit for you. You could even use a variable instead of "Player.X" and just call it CameraTarget. Then, if you want the camera to focus on something else, just change that variable once to something else. The currently-running camera positioning will still be in effect and it will smoothly switch over to the new object. Just change the CameraTarget variable back to the Player and you're back to regular gameplay.

    Also, using this in conjunction with LayoutScale can create some really neat things, but I'll spare you. More just hoping that people will see the solution in this thread and see they can take it further and do more.

  • I second the use of an invisible sprite as a pseudo camera. This gives you even more options including a smoothly-scrolling camera to make your game look silkier! Instead of Set position to Player.X, use lerp.

    Every Tick: Set Position to lerp(Camerasprite.X, Player.X+200, 7*dt), lerp(Camerasprite.Y, Player.Y, 7*dt)

    I think Sonic 1 for the master system uses this, but still be aware of the fact than the camera have to be at the good speed, or else, like sonic on the master system, you could have that problem:

    Subscribe to Construct videos now
  • thegrind, C-7, Thanks for the great input guys. C-7 that would allow us to make some great camera movements, will really give special feel to the game. Yup, Aphrodite, I think sometimes it happens here also, the system is unable to keep up with the mouse if it is moving too fast.

    I got mine to work perfectly. Yup use a dummy sprite for the scroll to behavior. I set the dummy to follow the player.x + (distance I want) and player.y if the dummy is not half screen away from the end of the layout. Works like a charm!

    Again, thanks guys!! Really appreciate your advices!!

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