How do I add another condition in this code?

0 favourites
  • 10 posts
From the Asset Store
5 levels with simple coding Source-code (.c3p) + HTML5 Exported
  • Hello,

    i have this code https://s9.postimg.org/wrb4qrvgv/helppppp.png and I want to add another condition into it. If the frame is 1 change the frame to 0, it should work every 25 score as well. I tried it in different ways, but every time it gets stuck and it is not changing at all. :/

    Appreciate every help!

  • Trigger once must be the last condition in the event, as documented in the manual and in the tooltip when you chose it as a condition.

  • Thanks for reminding me, but thats not the case in here... :/ I have 2 backgrounds and i want that the game will change background every 25th point, do you know ho to do it?

  • takamoto solution is almost correct.

    You indeed need to use subevents in which you check the animation frame number.

    You also absolutely need an else for the second sub event.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • takamoto solution is almost correct.

    You indeed need to use subevents in which you check the animation frame number.

    You also absolutely need an else for the second sub event.

    why we have to use else?

  • Look at the code. If frame=0 -> set the frame to 1

    Without the 'Else', event 5 will then checks if frame=1, which it does, because you just set it, so it sets it back to 0 again! 'Else' is critical to make sure only the one condition is checked at a time, and you don't flip-flop your values.

  • Look at the code. If frame=0 -> set the frame to 1

    Without the 'Else', event 5 will then checks if frame=1, which it does, because you just set it, so it sets it back to 0 again! 'Else' is critical to make sure only the one condition is checked at a time, and you don't flip-flop your values.

    What about "trigger once"? We can use trigger once for both event 4 and 5.Then it changes the frame once.

  • Nope, same thing will happen.

  • > Look at the code. If frame=0 -> set the frame to 1

    > Without the 'Else', event 5 will then checks if frame=1, which it does, because you just set it, so it sets it back to 0 again! 'Else' is critical to make sure only the one condition is checked at a time, and you don't flip-flop your values.

    >

    What about "trigger once"? We can use trigger once for both event 4 and 5.Then it changes the frame once.

    The events are already triggered once because you put trigger once in the top event, but C2 reads events from top to bottom so it'll check if = 0 then set to 1 then check = 1 and it is cause last event set to 1

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