Change location of Player in Scroll To Behavior

Get help using Construct 2

Post » Sat Oct 26, 2013 2:37 pm

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!
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

Post » Sat Oct 26, 2013 10:22 pm

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
B
26
S
9
G
2
Posts: 78
Reputation: 2,524

Post » Sun Oct 27, 2013 4:28 am

@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!!!
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

Post » Sun Oct 27, 2013 5:37 am

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.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Sun Oct 27, 2013 6:22 am

[QUOTE=C-7] 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)[/QUOTE]

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:

http://www.youtube.com/watch?v=zHHN098JHf0Aphrodite2013-10-27 06:22:28
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Sun Oct 27, 2013 11:51 am

@thegrind, @C-7, @Aphrodite. 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!!
B
46
S
23
G
31
Posts: 693
Reputation: 20,637


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 37 guests