0 Favourites

How do I check the animation frame of 10 instances

  • I want to check if the frame of 10 instances is the same at an event and if they are greater than 0 in another.

    I am trying:

    • to check if all the instances or some of them have the same frame:

    pick all sprite

    sprite is on-screen

    for each sprite

    sprite animation frame = sprite.animationframe

    • to check if the frame of all the instances are greater than 0:

    pick all sprite

    sprite is on-screen

    sprite animation frame > 0

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • For each (Object)

    Sprite is on-screen

    Sprite Animation Frame > 0

  • For each (Object)

    Sprite is on-screen

    Sprite Animation Frame > 0

    It's not working. If I change the frame of one of the instances, I get the answer.

  • 'mFrame' being max count of frames.

    Local variable 'OnScreen'

    Top level event : is on screen

    action ... set variable OnScreen to Sprite.pickedcount

    Sub event : Same event: System > For "i" = 0 to mFrame

    sub event : Sprite > Compare frame > frame = loopindex("i")

    In same event : System > compare 2 values .. 1st 'OnScreen' ... = .. 2nd Sprite.pickedcount

    action > stop loop

    action > whatever you like, because if this condition is true, they all have the same animation frame, set a local variable or so

    The other

    Local variable 'OnScreen'

    Top level event : is on screen

    action ... set variable OnScreen to Sprite.pickedcount

    sub event : sprite animation frame > 0

    sub event : system compare 2 values ... 1st OnScreen ... = .. 2nd Sprite.pickedcount

    action ... when this actions run, there is no sprite on screen with frame = zero

  • 1: I need to check if two or more instances are showing the same frame. if not the game goes ahead.

    2: It works well. Thanks

  • Instance variable 'ConfessColor'

    'mFrame' being max count of frames.

    Top event :Is on screen.

    (might need an action here ... set Sprite.ConfessColor to zero .. but i dont think it is needed)

    Sub event: System > For "i" = 0 to mFrame

    Same event : Sprite > Compare frame = frame = loopindex("i")

    action set instance variable Sprite.ConfessColor to Sprite.pickedcount

    Sub event under top parent : System > Pick highest .... Sprite.ConfessColor

    same event : system compare 2 values > Sprite.ConfessColor .. greater than ... 1

    action ... whatever you need, because if those actions run there are at least 2 sprites with the same frame. Understand that at this point only the sprites with Sprite.ConfessColor .. greater than ... 1 are picked. If you need to adress more sprites, you need a new top level event to start with.Preferable a function.

  • Great! It works like a charm. Thank you very much.

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