Zoom of an Object

Discussion and feedback on Construct 2

Post » Tue Jul 10, 2012 11:05 am

Hi all,
is there any method to do ZOOM of an sprite?
B
5
S
1
Posts: 49
Reputation: 723

Post » Tue Jul 10, 2012 11:14 am

Never done it. But I believe currently you have to use the scale action to do so. If there's a zoom plugin I don't know of it.
B
47
S
10
G
6
Posts: 455
Reputation: 8,326

Post » Tue Jul 10, 2012 11:55 am

i have tried many time before but failed , i really would like to know how ^^
B
48
S
15
G
6
Posts: 795
Reputation: 12,035

Post » Tue Jul 10, 2012 1:58 pm

Just multiply the OriginalWidth and OriginalHeight by a zoom factor. E.g. to zoom to 150%, set the size to:

Self.OriginalWidth * 1.5
Self.OriginalHeight * 1.5
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Tue Jul 10, 2012 3:13 pm

@Ashely , how can i do that??
see this picture

we want this layout scale fit the green square width and height and the pink square is just to see if its zooming in or not.

about your way i didn't understand it how can we put 2 values in scale in the condition there is 1 value
B
48
S
15
G
6
Posts: 795
Reputation: 12,035

Post » Tue Jul 10, 2012 3:18 pm

@Ashely :Yes I have use this solution with set size(sprite.width*50/100,sprite.height*50/100) and next to return to the origin size i use set size(sprite.width*100/50,sprite.height*100/50)
B
5
S
1
Posts: 49
Reputation: 723

Post » Tue Jul 10, 2012 3:31 pm

You can just use lerp. Its a bit of overkill, but it works.
lerp(original.size, target.size,1) would scale it to 100% of the target value, 0.5 would be half of that etc.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Tue Jul 10, 2012 3:45 pm

@zsangerous - that looks like a different problem - instead of zooming a single sprite, you want to adjust the viewport to fit an object. The best way to do that is set the window size to the size of the object and enable one of the scaling fullscreen-in-browser options.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Tue Jul 10, 2012 5:12 pm

@Ashely , sorry if i explained it on the wrong side , it must has scale on events , see this picture i hope it explain :
B
48
S
15
G
6
Posts: 795
Reputation: 12,035

Post » Tue Jul 10, 2012 8:39 pm

@zsangerous - so why not scale the orange box with the same scale applied to the green box? Or just scale the whole layer?Ashley2012-07-10 20:39:50
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Next

Return to Construct 2 General

Who is online

Users browsing this forum: KaMiZoTo and 13 guests