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

0 favourites
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • 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.

  • 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.

  • 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.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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)

  • 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?

  • 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?

  • 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.

  • Well, i have 2 PM's in my Outbox, for almost 2 days now.

  • 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!

  • I'm not clear what the issue is. In the initial capx you wanted to create multiple sprites and have each one have a different frame. The solutions you got so far seem to correct that.

    Your Larger capx just creates four different sprites. I can't tell from your descriptions how you want it to want it to work. and in what way the result not correct.

  • Hey, maybe we could swap e-mails?

  • I'm not clear what the issue is. In the initial capx you wanted to create multiple sprites and have each one have a different frame. The solutions you got so far seem to correct that.

    Your Larger capx just creates four different sprites. I can't tell from your descriptions how you want it to want it to work. and in what way the result not correct.

    Oh, hi, ROJO.

    Yeah, I threw a lot in there, but that's all easily programmable by me.

    Basically, in the larger capx I posted, the only difference is the spawned ships do not have static positions, but variable horizontal positions based on an array which picks some random non-repeating values out of a larger array and sorts them in ascending order and THERE the engine wash does not alternate. I just want it to alternate and I need the 4 frames. So no idea why that's happening. It only works sporadically right now, so gotta hit the F5 key a few times to reload to see it.

    So basically I need:

    spawned ship 1 starts at frame 0

    spawned ship 2 starts at frame 1

    spawned ship 3 starts at frame 2

    spawned ship 4 starts at frame 3

    spawned ship 5 starts at frame 0 (need to change the random values in there to 5 to see that)

    spawned ship 6 starts at frame 1

    etc etc depending on spawn size

    ---

    and maybe an alternate version if this proves complex

    so

    spawned ship 1 starts at frame 1

    spawned ship 2 starts at frame 2

    etc etc

  • Ok, now I can at least somewhat understand your events. The issue is event 44. To fix change it's condition to "else".

    what happens in that function is:

    if var != 4 then add 1 to var

    if var == 4 then set var to 0

    So if the var is 3 going into the function it will first change to 4 and then set to zero right after.

    The whole event sheet is kind of stretched out. You could simplify it to around 10 events i'd think.

    Edit:

    You're also messing with that frame variable at the end of the "Spawn_Ec_Ships" function. That probably also will cause the same kind of problem.

  • Yup, the Else fixed it for the 4 spawn (think i hit reload 15 times to test), but not for the 10 max spawn version or 7 for that matter (probably values larger than 4 for the spawned ships).

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

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