How do I "ping pong" between 2 numbers without randomization

0 favourites
  • 6 posts
From the Asset Store
The ultimate voice pack filled with 1,536 files of .......wav and mp3 of individual numbers, letters, and words (that go
  • Shake is one of the simplest things you can do.

    Just do it your self using variables, the random() expression, and the system scrollx, and scrolly.


    +> global variable "shake"= 1

    -->system scroll x to scrollx+random(-30,30)

    -->system scroll y to scrolly+random(-30,30)

    This worked.

    But I would want to have a stable shake (without random):

    (I want scrolly first to add VarNum1 pixels and then subsctract VarNum2 pixels)

    I tried:

    if shake = 1 --> system scroll y to scrolly+5

    --> set shake to 2

    if shake = 2 --> system scroll y to scrolly-5

    --> set shake to 1

    I expected the screen to go go up and down, moving 10 pixels (shake effect). But nothing happened.

  • By reading that it seems the program is reading it like this: shake = 1 so set shake to 2, now shake = 2 so set shake to 1. Thus it will just stay as shake = 1.

    Try using an else, incorporated into the second event, that should ensure it doesn't do both events.

    Example capx:


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks, Sumyjkl

  • You can use this: system scroll x to scrollx+choose(-30,30)

  • jastrazz I tried, but action "choose" also uses random.

    So it chooses sometimes 1 of the values more than once in a row.

    Sumyjkl solved it for me.

  • You could try the built in shake. Just add the "Scroll to" behavior and then call its shake action.

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