Object in Container Not Displaying Correctly Upon Initialization

0 favourites
  • 3 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Objects in question: Enemy (sprite) and Enemy_Life_Piece (also a sprite, dubbed ELP for this post).

    Event lines under the Enemies Group starting at event line 7.

    .c3p file: https://drive.google.com/open?id=1mDQ7d1IbTZcVgGcrrNBfhL89J9rvi-wt

    Controls: Arrow keys to move, spacebar to fire

    (Allow a few seconds to pass for Enemies to spawn from the center pillar in the game environment. Their movement system has been disabled for testing. They will spawn and stop once they are no longer overlapping the center ring. Up to a max of ten Enemies will appear around the edges of the center ring.)

    When an Enemy is spawned, the ELP is auto-spawned with it because they are in a container together. The Enemy has up to six stages (from a triangle to an octagon) with its own HP at each stage. The ELP is a kind of "health gauge" for each stage which "fills in" each of the slices of the Enemy's current shape (eg: if it's in its triangle stage, the ELP will show three transparent triangle slices). As the Enemy gets hit, the HP will drain and the animation frames of the ELP will display accordingly. So if the Enemy has a max HP of 75 and has only 25 HP or so left, only one triangle slice should be displayed via the ELP.

    Now, this system works in as far as continual attacks go. The problem I'm having is that when the Enemy is initially spawned, the ELP does not display correctly. In fact, it won't display correctly at all until it is reduced in its stage. If it starts out at the square stage, reducing it to the triangle stage will result in the ELP displaying correctly as the Enemy's HP is continually drained.

    I can't figure out why this is happening... Can anyone see what I'm missing?

    Thank you.

  • I did some investigation. It's because you don't update HP_Max until the enemy dies once. The initial HP_Max is 0 so your calculation for starting animation frame always ends up as 0.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Doh!!! So obvious... Thanks for that. I'll test it out when I get home. Thank you!

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