Spawn sprite and set animation frame

  • Got a sprite called "typeShow" that has 6 frames each of different colour.

    0 Green - 1 Purple - 2 Red - 3 Yellow - 4 Black - 5 Blue

    Trying to spawn this sprite and set the animation frame at the same time.

    Expected result 5 boxes of a different colour side by side Green - Purple - Red - Yellow - Black

    Currently the result is 4 Green and 1 Black

    typeLoop = 0

    typeQuantity = 5

    I have stopped the animation and set speed to zero and loop to no.

    So my question, is it possible to spawn an instance of an object and set it's animation frame correctly at the same time?

    Thanks

    Rob

  • so you'd like this?

    system for "" from 0 to 4

    create object typeshow at (loopindex*80,300)

    typeshow set animationframe = loopindex

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for your reply.

    Not sure where to put the *80

    Tried this:

    But it doesn't break out of the loop and creates about 10 zillion objects?

  • Whoops

    Nearly there, squares are all different.

    Still won't break out of the loop though.

  • Cause you probably run that loop every frame. If you want to run it only once then you have to add some "blocking" condition next to the "System for" loop. For instance add "On start of layout" or "trigger once" etc.

  • Unable to use "On start of layout" as it's triggered by other events.

    Tried the trigger once but still doesn't break out of looP.

    Will try trigger once and sub event now.

  • frozenpeas some demo to look at, you might find your answer here

    https://www.dropbox.com/sh/eioscti86bpr ... 7YPza?dl=0

  • Unable to use "On start of layout" as it's triggered by other events.

    Tried the trigger once but still doesn't break out of looP.

    Will try trigger once and sub event now.

    Well... if it is triggered by other events, shouldn't it be a sub-event of that triggered event?

    The loop shouldn't be run every tick, only when certain conditions are met it should run once..

    right now the "trigger once when true" has no further conditions, so it is triggered once per tick

  • Yes got it.

    I added it as a sub-event.

    Thank you to everyone

    Been away from the Construct 2 and this forum for a while and forgot how helpful everyone is - love this place

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