How do I set the origin point of a sprite in the event sheet

Get help using Construct 2

Post » Wed Mar 25, 2015 6:30 am

I am making a tool to show a map (a sprite), which the user can drag around with their mouse and zoom in and out of. When the user zooms in and out by using the mouse wheel, I increase / decrease the scale of the sprite in the event sheet. This looks nice and works well, however the point of origin of the sprite isn't relative to the 'view' (sorry i don't know the terminology yet), which means that when you zoom in and out, the point you were looking at moves out of view.

I would like to change the 'origin' image point of the sprite in the event sheet when the user zoom in / out to be relative the middle of the 'view' in order to make this look right, but i can't seem to find the option. Is this possible?
B
9
S
1
Posts: 12
Reputation: 448

Post » Wed Mar 25, 2015 6:44 am

It seems to be impossible with C2 basics.. Maybe someone can propose you a javascript solution..
B
8
S
1
Posts: 72
Reputation: 606

Post » Wed Mar 25, 2015 8:38 am

You could try adding multiple image points, so you could then choose the image point before you perform the zoom.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
136
S
31
G
87
Posts: 5,498
Reputation: 60,282

Post » Wed Mar 25, 2015 4:01 pm

you can also use smaller "helper" objects. make them invisible to start and reference them to scroll to instead of image points. You could even make the helper object follower your mouse.x mouse.y if you wanted it to zoom to the object where your curser was. just an idea
B
3
Posts: 6
Reputation: 187

Post » Fri Mar 27, 2015 5:16 am

@Jakzon not bad!! your solution is the best! and it must be realized!
B
8
S
1
Posts: 72
Reputation: 606

Post » Fri Mar 27, 2015 5:58 am

I have done this in my game for zooming in and out of the layout. You really don't need image points at all. Have your map sprite as a background and set the layout scale to zoom in and out.

I simply had if mouse real gos up change layout scale to ' current layout scale +1 ' and added a compair conditions saying the scale had to be larger than a number. Same with zooming out only reversed. doing this will zoom into the center of the screen.

The grab and scroll is a little more tricky but just say if mouse btn is down then set the scrollx and scrolly to mousex and mousey

I think that will work. My scrolling was done by moving the cursor to the edge of the screen but the above method should work.

<><><><><><><><>
here is a quick demo. Its rough but it is just to give you some ideas
https://www.dropbox.com/s/d2spgthpiw84nsq/ZoomDemo.capx?dl=0
"Were all mad here. I'm mad, your mad." "How do you know I'm mad?" Asked Alice. "You must be" Said the Cheshire Cat. "Or you wouldn't have come here"-Lewis Carroll: Adventures In Wonderland
B
7
S
3
Posts: 113
Reputation: 1,295


Return to How do I....?

Who is online

Users browsing this forum: DiegoSanudoDT and 9 guests