How do I add custom scrolling without ScrollTo behavior ?

Get help using Construct 2

Post » Mon Jun 16, 2014 7:02 pm

A bit of background: I am trying to create a retro side-scrolling platformer. For this I am using a Platform behavior on my player character, and enabled Integer coordinates in the view properties. Platform max speed is set to 80. Acceleration & deceleration are set to huge values like 1000 to get instantaneous speed changes. If I also add ScrollTo behavior to the player everything works fine.

Now I want to do some fancy custom scrolling and that's where things are breaking. I removed the stock ScrollTo behavior and added a very simple event to the bottom of the sheet:
Every tick: Scroll To X= Player.X

This almost works except scrolling stutters by 1 pixel. I see the player move past the center by 1 pixel and then he snaps back to the center one frame later. My theory is that the Platform behavior updates the Player.X after my events are run.

Can anyone confirm that is the case? If so, what are some workarounds to do custom scrolling without relying on ScrollTo ?
B
12
S
3
G
3
Posts: 73
Reputation: 2,647

Post » Tue Jun 17, 2014 12:20 am

Use the 'magicam' addon. It's the best solution for whatever cam thing.
B
20
S
4
Posts: 385
Reputation: 2,270

Post » Tue Jun 17, 2014 7:51 am

You could always write your own scrolling logic, which provides more control but of course is a huge pain in the neck and extremely time consuming...

In a platform example where there is only X movement, you only need one variable (generally I just call it scrollspeed). You need to have events updating on every tick that move objects based on scrollspeed. When the player presses left or right, instead of moving them, you set scrollspeed to -10 or 10, for example. You can also add extra events in the ticks to gradually ramp up and slow down scrollspeed for smoother transitions.

Needless to say this gets a little tricky, but it's how it's done outside of programs like Construct 2. At least, that's how I do it :P
B
5
Posts: 10
Reputation: 245

Post » Tue Jun 17, 2014 2:33 pm

I usually have a 'camera' object with Scroll To. If I need to focus somewhere, I just move this object.
B
53
S
11
G
6
Posts: 133
Reputation: 8,830

Post » Tue Jun 17, 2014 9:21 pm

Thank you, Zathan. I am looking at Magicam. My question though was more about using built-in functionality.

siks I think this would run into the same bug/limitation that I am talking about. Let's say you want to have the camera 40 pixels in front of the player. If you add an event "every tick: camera.x = player.x" this will exhibit stutter for integer views.
If the camera and player are linked via a Pin it works, however.

EDITED: Never mind. I must have had a stray event somewhere. I recreated the event sheet and now it's behaving as expected. :oops:
B
12
S
3
G
3
Posts: 73
Reputation: 2,647

Post » Fri Jul 25, 2014 10:40 pm

siks wrote:I usually have a 'camera' object with Scroll To. If I need to focus somewhere, I just move this object.


This is awesome coupled with MoveTo :)
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Tue Jul 29, 2014 8:55 pm

@codah Pretty much, yeah! :)
B
53
S
11
G
6
Posts: 133
Reputation: 8,830


Return to How do I....?

Who is online

Users browsing this forum: Alvaro2 and 15 guests