Secret of Mana movement

Get help using Construct 2

Post » Sun Nov 24, 2013 9:13 pm

I'm trying to figure out how to make the camera move like it does in the secret of mana. It seems to scroll with the player sprite but only if the player is within x distance of the game window edge. Here's a video to see what I mean. Secret of Mana movement Any idea how to do this? I can't figure it out.

Thank you
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,991

Post » Sun Nov 24, 2013 9:45 pm

You can use the viewport expressions to work it out, and have an invisible object with the scrollTo behaviour. So something like: distance(player.x,0,viewportLeft(0),0) < 200 = scroller move at angle: 180, 60*dt.

Hope that helps a little!
B
28
S
8
G
5
Posts: 429
Reputation: 7,007

Post » Mon Nov 25, 2013 12:19 am

Just give the player the ScrollTo behaviour.
B
47
S
17
G
81
Posts: 2,224
Reputation: 48,095

Post » Mon Nov 25, 2013 12:55 am

@Tobye That's basically what I'm doing now and it's not working how I would expect (though I'll continue playing with it).

@plinkie I wish it were that easy. :)
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,991

Post » Mon Nov 25, 2013 12:58 am

It is that easy? If the player has 8-direction and you give him ScrollTo behaviour, the viewport will follow the player when he reaches the edge of the screen.
B
47
S
17
G
81
Posts: 2,224
Reputation: 48,095

Post » Mon Nov 25, 2013 1:22 am

@plinkie - With scrollTo on the player it will always scroll so he is in the centre. You could disable it until he is near an edge, but then when you re-enable it it would snap to him.

Here's one way: capx

You can also do what I said before with move at angle. Or you could use a behaviour that sets the angle of motion to the player and decelerates when it gets close, lots of ways really. Just need to detect the viewport's distance to the player.

Hope it helps!
B
28
S
8
G
5
Posts: 429
Reputation: 7,007

Post » Mon Nov 25, 2013 1:35 am

@Tobye Cool, that's closer then I was able to get. I'll keep tinkering! Thank you.

@plinkie Just using ScrollTo on its own the camera will always scroll with the sprite, not just when the sprite is near the edge of the game window.
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,991

Post » Mon Nov 25, 2013 10:23 am

Instead of using the scrollto behaviour in this case it's probably much better to use the system scrollto action, setting up events and conditions for when to scroll and when not.

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Nov 25, 2013 10:44 am

web-example

capx

There are ways to do this with even less events, but I made the events so they can be easily understood.

This example would actually work just as good with scrollto-behaviour, but the big advantage of the scrollto action is that it's easier to handle through events. It doesn't have to be every tick. Also, you don't have to use an object to scroll to, it could just be done with coordinates..LittleStain2013-11-25 10:55:06
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Nov 25, 2013 4:01 pm

@LittleStain Thank you! That's exactly what I've been trying to achieve. Would you be willing to share your optimization ideas (how to do it with less events/sprites etc as you mentioned).

Also, I see you answering peoples posts every day and I just wanted to say how appreciative the community is for people like you who are so willing to help us out. Thank you!
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,991

Next

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 21 guests