Solved: Manage scroll behavior (Metal slug like)

Get help using Construct 2

Post » Wed Oct 19, 2011 1:35 pm

Edit : Solved :)
Thx to Kyatric Demo in this thread

Hi,


I would like the Horizontal scrolling only to move forward and to bound on the left part!

My game test : http://www.gamesrusher.com/test/ (Edit: now working)

Here is what I already thought :

I only needs the scroll when my player moves forward so here we are:

* Player is playing animation Right > System Scroll to player.x

It works but as soon as I press right the Player is back in the middle of the screen.


It would work if I could use Windows coordinates.
Like if Player playing animation right + is in the middle (or Window X coordinate) then System scroll to player.X

Like that When I go back it doesn't scroll and it starts scrolling only when I reach the middle of the window for example!

Also window coordinates could be helpful To bound the player.
Because right now if I go back , the player may not be on screen but he is still on the layout and I can't make it bound.

I could do it if I could just set an invisible Sprite on Left border of the window.



So am I going all wrong with that ?
What could do the magic ? Is there any Window coordinate to use ?

ThanxKetoulou2011-10-20 10:05:06
B
15
S
6
G
2
Posts: 34
Reputation: 2,122

Post » Wed Oct 19, 2011 8:23 pm

What you can do is compare the X position of your character to X of the window (viewport) / 2.

With this logic, if the X position of your character is greater or equal half of the X viewport, he'll be on the right, so set the camera to follow. If his X position is lower than half of the X of the viewport, he'll be on the left, so set the camera to stop following.

Good luck!
B
106
S
35
G
37
Posts: 798
Reputation: 25,215

Post » Wed Oct 19, 2011 9:22 pm

Thx andreyin for answering

What expression should I use ? Is it for Construct 2 ?

I can't find any window.x or viewport ! and also nothing about a camera !

Any help on that ?
B
15
S
6
G
2
Posts: 34
Reputation: 2,122

Post » Wed Oct 19, 2011 10:04 pm

Here is an implementation of what Andreyin said :
http://dl.dropbox.com/u/36472942/construct/forumhelp/BoundingScrollingEvents.capx

The capx is commented, and all is made so that modifying the dimensions of the player sprite or of the layout or even of the window automaticly works.

It is just an implementation. You'll surely have to adapt it to your project.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Thu Oct 20, 2011 7:53 am

Thank you Kyatric,

This is indeed very useful , I think you just solved my problem ! :)


Thx again I will try to adapt it asap !
B
15
S
6
G
2
Posts: 34
Reputation: 2,122

Post » Fri Oct 21, 2011 9:32 am

Hi again !

I tried to start scrolling at 30% of the windowwidth but no matter what I change to Kyatric example, it still scroll from the middle.

As a consequence I solved this by adding an invisible sprite at X distance from the player.X

Is there a way to do it without an invisible sprite ? or is it the good solution ?

Example (modification of Kyatric capx):

http://db.tt/xJAELYce

Just copy paste the link in your brower can't make it work on the forum directlyKetoulou2011-10-21 09:45:21
B
15
S
6
G
2
Posts: 34
Reputation: 2,122

Post » Fri Oct 21, 2011 9:37 pm

Event 4
You could make something like
Player.X >= Scroll.X - 200 -> set scroll.x to Player.X + 200

I feel 200 is not a good measure, but you can affine from there.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Thu Nov 03, 2011 4:18 pm

Hi,

So here is a follow up !

So far in Metalslug like games we can't go back and we scroll the player not from the middle ! And thx to Kyatric this now happening.

In Metal slug very often the camera stop until the hero kills all ennemies. When it's done there is a smooth camera movement which set again the player at 40% of the screen.

I had difficulties to find out how to have this smooth camera movement but I did something which is very close to that! At least I hope.

So let me know if i am right: basically I change Kyatric formula and used lerp to have a smooth scrolling effect after killing all ennemies.

My example file: Example file

You need to jump on the sprite 500 (ennemy) to kill him and see the effect i was looking for

Ketoulou2011-11-03 16:54:20
B
15
S
6
G
2
Posts: 34
Reputation: 2,122

Post » Tue Nov 08, 2011 12:26 pm

Metal slug is a good example, not in center of char.

I put a camera invisible char and I follow it. This moves only in X
B
203
S
37
G
13
Posts: 136
Reputation: 29,523

Post » Wed Apr 10, 2013 7:06 pm

Hi everybody,

I want to do a metal slug like and i was very happy to find this topic with this capx.
But i need that the camera follow the player in Y if the player reach the middle of the screen. I past three days on it but i didn't do anything usefull... Can you help me ?
B
7
Posts: 28
Reputation: 633

Next

Return to How do I....?

Who is online

Users browsing this forum: austinblackbelt, Google [Bot], makkancs and 35 guests