scroll camera platform game window in parts

Get help using Construct 2

Post » Mon Dec 23, 2013 12:15 pm

I'm sure it's somewhere on the forum was an example of what you need but I can not find it.
So when player sprite is touch edge of game window, game window skip forwart moves about the size of what is total size of the game window. (in up down left or right)

So camera should scrolls for example every 800 pix pixels (left and right) but 480 pix (up and down)delgado2013-12-25 13:52:54
B
109
S
26
G
46
Posts: 1,886
Reputation: 35,168

Post » Mon Dec 23, 2013 6:17 pm

bump
B
109
S
26
G
46
Posts: 1,886
Reputation: 35,168

Post » Mon Dec 23, 2013 6:55 pm

I can't open Construct 2 now to make an example, but try taking a look at this:

(can't post URL, so take a look at the FAQ, in the link "Metal Slug/Mario type of scrolling")

With this logic, I guess it's easy to fit your style of camera in your game.

I'll try to do an example as soon as I can. I was trying earlier today but I had some problems.

The idea I was trying is that if the player hits the end of the window, you scroll the camera accordingly (with Scroll X and Scroll Y in "System").

Another idea was to create an invisible sprite in the middle of the screen, add the behavior "scroll to" in it and if the player goes beyond the window (viewport), you change the position of the invisible sprite accordingly. It worked, but I couldn't find a way to make it move smoothly (so it's a nice effect). It always moved absolutely, so the camera moved to abruptly.

I hope what I said made sense. I'll try and make a example when I can, but I'm in a hurry right now. So I'm sorry if I wasn't clear enough in my instructions, I wrote it fast.
B
7
S
1
Posts: 15
Reputation: 589

Post » Mon Dec 23, 2013 7:24 pm

Try:
System Every Tick
System: Set Scroll X to scrollx + clamp(LayoutWidth /2 + floor(MySprite.X /LayoutWidth) * LayoutWidth - scrollx,0-dt*scrollSpeed,dt*scrollSpeed)

System: Set Scroll Y to scrolly + clamp(LayoutWidth /2 + floor(MySprite.Y /LayoutWidth) * LayoutWidth - scrolly,0-dt*scrollSpeed,dt*scrollSpeed)

Where MySprite is the character that triggers the movement and scrollSpeed is a variable that you can use to set whatever speed of transition you require.

Is this what you mean?
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,386
Reputation: 58,454

Post » Tue Dec 24, 2013 12:50 pm

@zenox98 @Martiny Please take a look at this example:
https://dl.dropboxusercontent.com/u/44710358/Viatoree.exe
B
109
S
26
G
46
Posts: 1,886
Reputation: 35,168

Post » Tue Dec 24, 2013 3:06 pm

bump
B
109
S
26
G
46
Posts: 1,886
Reputation: 35,168

Post » Tue Dec 24, 2013 6:10 pm

@delgado

Here's a example I made that hopefully is what you want.

What I've done there is this:

I create the background, the player and a invisible sprite that I called "camera".

"camera" has the scrollTo behaviour, so the camera is always following this sprite.

I align the camera sprite in the middle of the window, by clicking in it, "Align" -> "Window" -> "center horizontal" / "center vertical".

Then in the event sheet I see if the player passes the viewportRight or Left. If yes, I move the "camera" sprite according to the windows width size of the project. In this case it's 640, so I put 640. If you ever change the windows width in the Project Properties, change the 640 to the new value you changed. (but don't forget to align horizontal/vertically again, otherwise it will not work as expected).

I hope this is what you want and that my explanation is clear. English is not my first language.

https://www.dropbox.com/s/d62dj98kbqh2ccd/camera-example.capx


Edit:

There's an error if you go all the way to the end of the layout and then go back. The camera don't align properly... well, I don't now how to fix it. I'd try to take a look at it now, but new it's christmas and I don't have that much time. Sorry.Martiny2013-12-24 20:32:44
B
7
S
1
Posts: 15
Reputation: 589

Post » Wed Dec 25, 2013 1:51 pm

@Martiny its good when i go left and right but when i walko up and down nothing happens. Thanks for your trouble.

Im still looking for solution, someone Please take a look at this example:
https://dl.dropboxusercontent.com/u/44710358/Viatoree.exedelgado2013-12-25 13:52:29
B
109
S
26
G
46
Posts: 1,886
Reputation: 35,168

Post » Wed Dec 25, 2013 2:19 pm

Martiny's example is all you need. Just look at the code and add events for Y. You shouldn't really need to be spoon-fed this after the amount of time you've been using C2.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,386
Reputation: 58,454

Post » Wed Dec 25, 2013 4:55 pm

@@Martiny It took me a moment to adapt your example to my needs and you know what? it works :) thanks for a great example!
B
109
S
26
G
46
Posts: 1,886
Reputation: 35,168

Next

Return to How do I....?

Who is online

Users browsing this forum: David181, OBLIVION and 58 guests