Zooming

For questions about using Classic.

Post » Fri Jun 05, 2009 4:24 pm

I'd like to have my camera zoom out when ever the player moves. The camera must zoom out based on the charcters movement. Please? :D
B
1
G
4
Posts: 9
Reputation: 1,043

Post » Fri Jun 05, 2009 4:33 pm

Use the set display zoom action or set layer zoom actions. You can base the zooming in/out on your character's movement speed using a simple formula, using time conditions or timers to do it incrementally.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Fri Jun 05, 2009 5:06 pm

Could you tell me how to do that? I've tried this: Set the zoom based on the charcters X and Y. That didn't work though.
B
1
G
4
Posts: 9
Reputation: 1,043

Post » Fri Jun 05, 2009 5:50 pm

You'll want to set the zoom based on the distance between the two. Try:

Always
Set zoom to dist(player1.x, player1.y, player2.x, player2.y)

You're going to have to tweak the equation to get it to zoom the right amount, like multiplying it by some amount, but that's the expression you'll use.

I can't remember, is zoom 50 smaller or larger than 100%? The value might be backwards.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,422

Post » Fri Jun 05, 2009 6:24 pm

I think he's looking for an almost acceleration based zoom; so when the player starts moving the camera zooms out slowly.

You need to get the player's distance from previous position at some time interval (Say 100ms) and base your zoom on that. Create a global variable (or private tied to the character) storing the characters X (if its a platformer) every 100ms then checking against its previous position; that will give you "The distance traveled since the last update" and a number to base your camera zoom on.
B
2
G
3
Posts: 43
Reputation: 936

Post » Fri Jun 05, 2009 10:43 pm

[quote="Mitch":to1pad1n]You need to get the player's distance from previous position at some time interval (Say 100ms) and base your zoom on that.[/quote:to1pad1n]
...which is equivalent to it's speed, which Rich pointed out:

[quote="Rich":to1pad1n]You can base the zooming in/out on your character's movement speed using a simple formula[/quote:to1pad1n]
So you just need to set the X and Y zoom ratios to something like 100 - player[movement].speed / 10. Something like that. Play with the numbers to get it exactly right. No need for anything more complicated.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Sat Jun 06, 2009 5:50 am

I didnt even know about the [platform].speed property yet :P you guys are making things too easy for people! 8)
B
2
G
3
Posts: 43
Reputation: 936

Post » Sun Jun 07, 2009 12:39 am

I used acceleration based zoom for the 8-direction object in the same way Ash points out. It's really smooth and pleasant.

add some modulation to adjust the speed of the zooming (current = current + (target - current)*modulation)
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests