view problems

Just started using Construct 2? Post your questions here

Post » Thu Aug 13, 2015 2:12 am

How do I make a camera scroll to layout edges with a static hud?

basically I wan't to have the camera follow my player with a x and y offset
and then my player is near the edge of the room the camera adjusts itself so the player does not go behind the hud

Edit hey I can post I guess it wasn't to do with rep :D

Edit again oops forgot urls can't be posted :(
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Thu Aug 13, 2015 8:01 am

I do stuff like this by having an invisible sprite called "camera" that follows my player wherever I want it to. I then set the game to follow that object, so you can just set up a few states in your game (like measure of player's position is within x pixels of layout edge) to know when to reposition the camera object relative to the player. I generally use lerp to move the object, too, so it isn't jumpy but remains smooth.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Thu Aug 13, 2015 6:10 pm

could you post a example equation?
also would I scale the camera object to fit inside of the view square or would I make it the same size as the player?
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Thu Aug 13, 2015 6:35 pm

Umm I should have one sitting around somewhere, but I'll try to whip something up. And the camera object is just the center/focal point with the "scroll to" behavior on it, so the size doesn't matter. If you want to zoom in/out, you would use layoutscale. You could set it with variables and such, but it'd be done with layout scale.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Thu Aug 13, 2015 6:40 pm

k thankyou
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Thu Aug 13, 2015 7:44 pm

Here you go. I don't know where your UI elements are on-screen, so I just gave you the skeleton you would need to be able to reposition and zoom the camera however you see fit to avoid things. I turned unbounded scrolling to yes just to show solely what the camera code does. This is by no means a definitive or perfectly-featured camera for platformers, but it gives you a good starting point.

Demo: Running in the browser

Capx: Camera
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Thu Aug 13, 2015 7:51 pm

I can't open it.
are you using a beta version of C2?
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Thu Aug 13, 2015 7:54 pm

Yes it's made in r211.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Thu Aug 13, 2015 8:05 pm

it not a platformer its a asteroids like game
also what is the target for?
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Thu Aug 13, 2015 8:18 pm

You never stated your genre (I can't guess), but the exact same principles apply to any type of movement. A platformer is simple way to showcase things. The target is to make it easier for you. Any offsetting or shifting focus can be done by just telling the target where to go and the camera object will automatically handle the movement for you. You also didn't say where UI elements were positioned on the screen that you wanted to avoid, so I just gave you the tools in that example to offset things however you need.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest