Implementing a dragon tail with chained sprites



  • Hello there!

    After finishing the HaxeFlixel tutorial I made a simple, bare-bones Flappy Bird clone. Then, I had the idea of making a dragon the character of that Flappy Bird clone game.

    Long story short: I'm trying to make a "tail" for the dragon that would follow the head's movements (see this video for an example: https://youtu.be/PMWh8n3CHw4?t=2m18s).

    I tried a couple of things:

    • storing the head's positions in an queue and applying those positions to the tail "chunks" with a delay (based on the FlxTrail addon): this kinda works, but the movement of the tail is far from fluid.
    • store commands (jump, fall) in a queue: this fails because the "fall" command sets acceleration.y = GRAVITY on the tail sprites (following the head), and because of the delay, the velocity accumulates more for each part of the tail.

    In any case, I'm wondering if there's a standard way of doing this (since I saw it in many games), as I feel it should be simple, but my inexperience in graphics programming doesn't allow me to get it right :(



  • Just an idea: Make each body part follow the preceding part: the first part follow the head, the second follow the first and so on. By storing the position of each part and you know what you do. Or use FlxVelocity.moveTowardsObject every few frames.



  • Hey @DleanJeans, thanks for replying :-)

    Make each body part follow the preceding part: the first part follow the head, the second follow the first and so on. By storing the position of each part and you know what you do.

    Yes, this is kind of the approach I tried. You can see the actual problem I'm having here (the single-element tail seems to skip frames):
    alt text

    Or use FlxVelocity.moveTowardsObject every few frames

    I'll give that a shot :-)

    Thanks again!


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.