How do I keep my camera on the center of the screen?

Get help using Construct 2

Post » Wed Jun 22, 2016 6:57 pm

Message: Versanthus can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Hey, it's me again.

I tried to create a camera that follows my character, the camera sprite follows but it doesn't scroll the camera to the left/right when the character is walking to the left/right.

What I do:
I create a new sprite object, give it scroll-to behavior and make it invisible (visible for now).
Then I code the object to follows my sprite objects. My character can transform between 2 sprite objects.

The code:
PlayerHuman, is visible | Camera, Set position to (PlayerHuman.X, Camera.Y)

System, Else | Camera, Set position to (PlayerFox.X, Camera.Y)

Files:
https://drive.google.com/open?id=0B5ofn ... lo1Q29MNkU

(The camera function should start on Level 1 - Forest.
Tutorial Level should be a fixed camera, so there is no issue with that.)
B
7
S
1
Posts: 13
Reputation: 401

Post » Thu Jun 23, 2016 2:37 am

I don't think you would need the camera at all. You can enable/disable ScrollTo in events. So you could add ScrollTo to both players next use if PlayerHuman is visible add the events ScrollTo PlayerFox disabled and ScrollTo PlayerHuman enabled. Else ScrollTo PlayerFox enabled and ScrollTo PlayerHuman disabled.
B
7
S
2
G
1
Posts: 4
Reputation: 1,037

Post » Thu Jun 23, 2016 7:31 am

Rexro wrote:I don't think you would need the camera at all. You can enable/disable ScrollTo in events. So you could add ScrollTo to both players next use if PlayerHuman is visible add the events ScrollTo PlayerFox disabled and ScrollTo PlayerHuman enabled. Else ScrollTo PlayerFox enabled and ScrollTo PlayerHuman disabled.


I tried that before. It doesn't work. The characters can still walk out of the screen.
B
7
S
1
Posts: 13
Reputation: 401

Post » Thu Jun 23, 2016 7:37 am

I found out the problem here. Apparently, something on my layout was creating the problem. I tested on a new layout, no problem whatsoever.
B
7
S
1
Posts: 13
Reputation: 401

Post » Thu Jun 23, 2016 6:48 pm

Good to know that you figured it out, good luck with your game!
B
7
S
2
G
1
Posts: 4
Reputation: 1,037


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests