How do I set animation frame to different fram but ?

0 favourites
  • 10 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • hello guys,

    i have a sprite ith 4 animation frame (red, green, yello and purple)

    i want that on every start of layout set frame to different frame (colors)

    but every time different frame but not repeated

    can you check the capx

    thank you

    https://ufile.io/6wwac

  • Since you already have all 4 sprites on the layout you can do this:

    System: For Each sprite (ordered), order by random(1) -> Sprite set animation frame to loopindex

  • Since you already have all 4 sprites on the layout you can do this:

    System: For Each sprite (ordered), order by random(1) -> Sprite set animation frame to loopindex

    can you be more specific ? i can't understand

    thank you

  • I can't be any more specific!

    On start of layout - add another sub-event:

    System -> For Each (ordered)

    Object: YourSprite

    Expression: random(1)

    Add this action: YourSprite set frame to: loopindex

  • I can't be any more specific!

    On start of layout - add another sub-event:

    System -> For Each (ordered)

    Object: YourSprite

    Expression: random(1)

    Add this action: YourSprite set frame to: loopindex

    it work fine if the sprite are already in the layout

    but if i destroy them and recreate them it not work

  • If you recreate 4 sprites, use "Wait 0" and then run then the same "For each (ordered)" loop. It will work.

  • > I can't be any more specific!

    >

    > On start of layout - add another sub-event:

    > System -> For Each (ordered)

    > Object: YourSprite

    > Expression: random(1)

    > Add this action: YourSprite set frame to: loopindex

    >

    it work fine if the sprite are already in the layout

    but if i destroy them and recreate them it not work

    Instead of the "on start layout" condition, use your sprite's "on create" condition.

  • >

    > > I can't be any more specific!

    > >

    > > On start of layout - add another sub-event:

    > > System -> For Each (ordered)

    > > Object: YourSprite

    > > Expression: random(1)

    > > Add this action: YourSprite set frame to: loopindex

    > >

    > it work fine if the sprite are already in the layout

    > but if i destroy them and recreate them it not work <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad"> <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad"> <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

    >

    Instead of the "on start layout" condition, use your sprite's "on create" condition.

    i did spent all the night trying to done it without any success

    can you take a look on my capx ? https://ufile.io/2cf4q

    thank you

  • This method with "For each" loop won't work in "On created" event!

    It only works after all sprites are fully created, hence "Wait 0".

    Also, if you have "For each" in the same event where you created sprites, you need to use "System Pick all" first.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dop2000

    thanks a lot

    that worked like a charm

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