Need help with simple zoom

Get help using Construct 2

Post » Sun Jan 19, 2014 3:04 am

Hi all!

I want to make a very simple zoom system,
when you press V the layout zooms 2x its original size,
and if I press V again it goes to its normal size again.

This is what I've made:



But for some reason it doesn't work,
but if I change one of the "Press V" conditions to another key,
it works..
But having 2 different keys for the same action is ridiculous.

Could someone help me please?
B
6
S
1
Posts: 67
Reputation: 636

Post » Sun Jan 19, 2014 3:59 am

Think about how events run. You have two trigger events with the same trigger condition (v is pressed). They can't run at the same time, so one is running directly after the other. Let's assume they are running in the same order as the event sheet (doesn't really matter):

//

event 1:

condition: when v is pressed, if foo is 0:

action: set layout scale to A, and set foo to 1

event 2: when v is pressed, if foo is 1 (which it is now, because you just set it with the previous event):

action: set layout scale to B, and set foo to 0

//

See? When you press V, you are running both events one right after the other, and ending up right back where you started. That's why it works when you change one of the keys: now, only one event is being triggered, and the toggle works as intended.

Hope that helps.

Cheers, T
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Sun Jan 19, 2014 6:41 am

TiAm is correct.

so, the way to fix it is to have a main event:
Keyboard on V pressed

then a sub event:
System zoom = 0 - set layout scale to 2 and set zoom = 1 (the way you have it above)

then another sub event that says:
ELSE - set layout scale to 1 and set zoom = 0

(the else section wont run if the first sub event is true, when zoom=0, even though the value of zoom gets set to 1)AllanR2014-01-19 06:44:16
B
96
S
33
G
20
Posts: 438
Reputation: 17,665


Return to How do I....?

Who is online

Users browsing this forum: 25games, Artcadev, brunopalermo, MaxxMunnn, mcscooter, Soluna Software and 27 guests