scrolling camera / maths help

For questions about using Classic.

Post » Wed Apr 02, 2008 6:08 pm

I want to scroll the screen to an object and have it slow to a halt when it reaches it's position, so i set the screen pos to a box, gave the box the ball movement behaviour then set it's speed to the distance between the box's xy and objects xy, but the speed stays constant.

Any help? Thanks.
B
37
S
19
G
18
Posts: 615
Reputation: 10,235

Post » Wed Apr 02, 2008 6:36 pm

You need to "set speed to speed -/+ something." If you "set speed to (distance between stuff)" then it might not behave properly. Try "set speed to speed - (distance between stuff)"
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Apr 02, 2008 6:38 pm

I don't think that will work because i never know how far away the camera and object is so it's speed might slow to 0 before reaching it, or overshoot.

I've uploaded my test.

press a key to move to the next object.

[url:11s9in42]http://www.mediafire.com/?fuend10mejm[/url:11s9in42]

I'm still learning construct so maybe theres an easier way i havent discovered yet.
B
37
S
19
G
18
Posts: 615
Reputation: 10,235

Post » Wed Apr 02, 2008 6:46 pm

I edited my post, sorry. I really need to read whole posts instead of just jumping to conclusions.

I'll try your .cap now...
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Apr 02, 2008 7:37 pm

I've fiddled with it for a bit and I can't seem to get it to work the way you want. I'm assuming that you want the box to move faster the farther away from it's target it is? I can't seem to work out how to slow it down from an unknown speed and distance that way.

If I set your box to a constant speed each time I can get it to slow when it's within a certain range of the target, and stop on target, but it starts at the same speed no matter how far away the next target is. And unfortunately if two consecutive targets are very close (within 100 pixels) then the box will overshoot the second.

Sorry, I'm not that good at math. Maybe someone else can help you out. :?
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Apr 02, 2008 7:44 pm

Ok fixed i just changed the "Distance(Box.XY,Sprite.XY)" to "Distance(Box.X,Box.Y,Sprite.X,Sprite.Y)"

[url:66eko8ws]http://www.mediafire.com/?fjib9tdytm9[/url:66eko8ws]
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Wed Apr 02, 2008 7:49 pm

Doppel's suggestion works, but I don't know why using .xy doesn't work (it is meant to!). I'll investigate since it's a bug.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Wed Apr 02, 2008 7:53 pm

Ashley maybe becouse the Box.X is just a value and Box.XY is {x,y} for ex. Box.X=20 , Box.XY= {20,50}
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Wed Apr 02, 2008 7:55 pm

[quote="Doppel":2yg9z9r8]Ok fixed i just changed the "Distance(Box.XY,Sprite.XY)" to "Distance(Box.X,Box.Y,Sprite.X,Sprite.Y)"

[url:2yg9z9r8]http://www.mediafire.com/?fjib9tdytm9[/url:2yg9z9r8][/quote:2yg9z9r8]

Oi, of course it's something simple like that. I even used (Box.X,Box.Y,Sprite.X,Sprite.Y) to detect distance to slow down my flat-speed test, but I never thought to change it in the action.

Good job, Doppel :)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Apr 02, 2008 8:07 pm

@deadeye - yep like they say "The darkest place is under the candlestick."

Also i found quickly solution becouse i was experimenting with .XY function.
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest

cron