Set Scroll to Playersprite + Mouse

Get help using Construct 2

Post » Mon Jun 01, 2015 6:57 pm

Hey, so I want to have the scrolling set relative to the player sprite's position and the mouse position. Currently I'm using:

Every tick > Scroll to (abs(Sprite.X+Mouse.X)/2), (abs(Sprite.Y+Mouse.Y)/2)

which works OK, but I want the view to centre more around the player sprite so that there's more of a "pull" to the player's position. At full stretch the view should centre around 1/4 of the distance between player and mouse, originating from the player. I've tried a few things with the numbers and I'm sure it's simple, but I can't seem to figure it out!
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Mon Jun 01, 2015 7:13 pm

This can be useful.

Image
I'm a Magician, not a Developer.
B
22
S
8
G
25
Posts: 106
Reputation: 14,294

Post » Mon Jun 01, 2015 7:24 pm

Thanks - there's no way to do it just by adjusting my initial event? I'd have thought that since I've already got the effect I want and just want to adjust the parameters a bit it'd be easy, but maths makes my head hurt :P
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Mon Jun 01, 2015 7:35 pm

Well, maths and programming - not my strong side.

That screenshot on top - result of my headache :)
I'm a Magician, not a Developer.
B
22
S
8
G
25
Posts: 106
Reputation: 14,294

Post » Mon Jun 01, 2015 8:08 pm

I would create an invisible sprite with the scrollto behavior

System every tick
Sprite set position to object player
Sprite move = 0.25*(distance(player.x,player.y,mouse.x,mouse.y))px at angle = angle(player.x,player.y,mouse.x,mouse.y)
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 Jun 01, 2015 9:49 pm

Thanks! @XpMonster 's solution worked fine for me, I just can't help thinking there ought to be a neater way to do it.
B
15
S
4
G
1
Posts: 286
Reputation: 1,988


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests