How do I reference odd or even numbers?

  • I currently have a line that works perfectly for a similar need that reads:

    sprite animation frame > 0

    I need to change it to something like:

    sprite animation frame = (odd or even numbers)

    I thought this would work but it doesn't seem to:

    sprite animation frame = 1|3|5|7|9|11

    I need it to trigger when ANY one of these odd frames are active. I think what is happening is it is returning a 1 or a 0, so in effect I am saying that if the animation frame is any one of these odd numbers then the animation frame =1. I need it to to trigger on something like animation frame=7.

    Or maybe I am approaching it all wrong.

  • sprite animation frame % 0 will equal 0 if even, 1 if odd.

  • [quote:3ax20ofn]sprite animation frame % 0 will equal 0 if even, 1 if odd.

    I'm not sure what the "%" is telling me.

    [quote:3ax20ofn]sprite animation frame = 1|3|5|7|9|11

    In the above example, if the active frame is odd and it returns a result of 1(being true), does "sprite animation frame = xx" ultimately become:

    sprite animation frame = 1

    and if even(false):

    sprite animation frame = 0

    Is this correct?

  • if Sprite.AnimationFrame % 0 = 0 -> do even code

    else -> do odd code

  • Pick the sprite

    System compare two values ... sprite animation frame % 0 = 1

    _____________ actions run if sprite animation frame = odd

    Does the same, just more simple

    % means modulo, or 'remainder after division', it is an operator like + - / *

    say .. 5 % 3 ....>... 3 goes 1 time in 5 with a remainder of 2

    so .... 5 % 3 = 2

    edit, i see you got an answer, i post anyway

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you very much

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