Need help with simple zoom

0 favourites
  • 3 posts
From the Asset Store
Simple and easily editable template for a dynamic camera that zooms in and out based on how far apart the players are.
  • 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:

    <img src="" border="0" />

    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? <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • 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)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)