Set Animation Frame Revisited Capx Attached [C2] [SOLVED]

Just started using Construct 2? Post your questions here

Post » Sun Jul 16, 2017 10:08 pm

Hey, guys.

Can anybody help with this capx?

Not sure what I'm doing wrong.

The 2 frame version seems flawless, meaning the engine wash will always alternate no matter how many times you hit F5/reload on Chrome, but the 4 frame version seems broken.

I had this set up w/ actual assets on much more complex arrays and it would work sporadically, the engine wash would not always alternate.

Not sure why.


As an example, this capx is always broken - the 3rd and 4th ship to the right have same engine wash/do not alternate.

http://www.darksunpictures.com/public/testupload.zip

I think I wasted way too much time on this, but I tried it a lot of different ways and not sure why it either works sporadically or not at all.

The sporadic version basically picked X random positions out of a larger array for spawns and sometimes it would alternate flawlessly, sometimes be weirdly messed up in places (no alternation, typically by 2's).

---
Just updated the capx. Thought it was broken, but no, just needs to be unzipped to load.
Last edited by AmpedRobot on Tue Jul 18, 2017 11:31 pm, edited 1 time in total.
B
35
S
19
G
18
Posts: 242
Reputation: 12,732

Post » Mon Jul 17, 2017 3:53 am

Hey Amped. The problem is with the 'EC_Ship_Animation_Frame_Counter' variable.

The reason why the 3rd and fourth are always the same is because you have the number going up to 5 when there are only four frames (so instead of resetting back to 0 it picks the last frame in the animation again).

In event 8 change the comparison to 4 instead of 5.
ImageImage
B
121
S
23
G
7
Posts: 1,070
Reputation: 13,039

Post » Mon Jul 17, 2017 4:45 am

Thank you so much for answering on a Sunday.

I guess I went crazy there for a sec!

But you're right it should be 4.

This works for multiple ship types too.

This helped me figure out why it was sporadic.

The array which rips out the random values out of the larger array does not do so in sequence, so the ships do no appear in sequence.

Don't suppose you know how to sort a1-dim array in C2, so the values appear from lowest to highest? Or plug them into a new array sorted?

0 1 2 3
63 64 65 66

Had no idea this would be this complicated for such a simple thing :p

---
Uhm, actually it's not a sort issue.
B
35
S
19
G
18
Posts: 242
Reputation: 12,732

Post » Mon Jul 17, 2017 8:50 am

Believe me, i tend to over complicate thing too. Usually i just start from scratch at 1 point.

https://www.dropbox.com/s/u1ix6d1hy9szl ... .capx?dl=0

You had only 1 problem.

See, consider ship B en ship C. C being on the RIGHT side of B.
IF the animation now starts with B on frame 0 and C on frame 1 ....
THEN the next cycle B has frame 1 and C has frame 2.
Well, then, where did frame 0 go ? It is on A !!!!!
So your animation moved from the RIGHT to the LEFT.
Since you have 7 ships and 4 frames, and you force your brain to see an animation that goes from left to right, you can only see chaos. Whatever you try, you can not see it. (Now you see the blue dot go from the right to the left, because i explained it to you)/

See how i solved that.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Jul 17, 2017 5:00 pm

Hi, thank you very much.

That is a very interesting way of doing that.

Could you per chance look at the larger capx because the issue is still there and I can't figure out why?

I thought it was a sort issue, so I sorted the array, but it still works only sporadically for alternating the engine wash.

http://www.darksunpictures.com/public/LARGERCAPX.zip

(please ignore pm just realized these sit in outbox for a while)
B
35
S
19
G
18
Posts: 242
Reputation: 12,732

Post » Mon Jul 17, 2017 5:06 pm

Wait, I just reread what you said.

Are you saying this is some sort of an optical illusion depending on how many ships you have?

Because I did want to do varying numbers of ships, between 4 and 7 for the random spawn I believe, maybe less for mobile due to performance issues and everything else I have in there.

So the solution would have to be individual based on how many different ships you spawned?

Full max spawn per array would be 10.

And full spawn per screen would involve 2 arrays of 10, so... ? (just 1 array below another)

Are you saying these animations, when you have a spawned row are processed RIGHT to LEFT?
B
35
S
19
G
18
Posts: 242
Reputation: 12,732

Post » Mon Jul 17, 2017 5:25 pm

Also, on the 2nd array below the 1st my dream list would involve that ship starting with an alternate engine wash versus the 1st ship in the array above.

@99Instances2Go I tried adapting your code for the multiship, different position version even though I don't really understand what it's doing.

Why do you have the Cycle local variable as %4 of 40 in there or 1.6? It doesn't even show up in the debugger, I guess same as all local variables.

Is skip essential there or just for placement?
B
35
S
19
G
18
Posts: 242
Reputation: 12,732

Post » Tue Jul 18, 2017 7:16 pm

@Ashley Alright, if nobody has any ideas I'll have to do this the old fashioned way with multiple animations, but that will really waste memory, reduce performance, and the quality of the game.

I think something this simple as set animation frame should really be working on something like this.
B
35
S
19
G
18
Posts: 242
Reputation: 12,732

Post » Tue Jul 18, 2017 8:18 pm

Well, i have 2 PM's in my Outbox, for almost 2 days now.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Jul 18, 2017 8:20 pm

99Instances2Go wrote:Well, i have 2 PM's in my Outbox, for almost 2 days now.


Oh, hey man.

Yeah, didn't get anything. Ok, no worries I'll wait!

I noticed that too. I have a few sitting for 6 days now. Weird!
B
35
S
19
G
18
Posts: 242
Reputation: 12,732

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: plinkie and 1 guest