Spawn sprite and set animation frame

Get help using Construct 2

Post » Tue Jan 26, 2016 1:15 pm

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


Image

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
Last edited by frozenpeas on Tue Jan 26, 2016 1:29 pm, edited 1 time in total.
B
9
S
3
Posts: 146
Reputation: 1,150

Post » Tue Jan 26, 2016 1:29 pm

so you'd like this?

system for "" from 0 to 4
> create object typeshow at (loopindex*80,300)
> typeshow set animationframe = loopindex
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jan 26, 2016 1:43 pm

Thank you for your reply.

Not sure where to put the *80

Tried this:
Image

But it doesn't break out of the loop and creates about 10 zillion objects?
B
9
S
3
Posts: 146
Reputation: 1,150

Post » Tue Jan 26, 2016 1:46 pm

Whoops

Nearly there, squares are all different.

Image

Still won't break out of the loop though.
B
9
S
3
Posts: 146
Reputation: 1,150

Post » Tue Jan 26, 2016 1:51 pm

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.
Image
B
27
S
16
G
60
Posts: 893
Reputation: 34,400

Post » Tue Jan 26, 2016 1:59 pm

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.

Image

Will try trigger once and sub event now.
B
9
S
3
Posts: 146
Reputation: 1,150

Post » Tue Jan 26, 2016 3:56 pm

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

https://www.dropbox.com/sh/eioscti86bpr ... 7YPza?dl=0
B
239
S
37
G
15
Posts: 1,923
Reputation: 39,758

Post » Tue Jan 26, 2016 4:13 pm

frozenpeas wrote: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.

Image

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
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jan 28, 2016 1:10 pm

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
B
9
S
3
Posts: 146
Reputation: 1,150


Return to How do I....?

Who is online

Users browsing this forum: ColombageEnPLS, darkrealos, pmerineau and 4 guests