game-maker-studio-2game-maker-language

How to draw sprites on an arc pattern in GMS2?


I've been trying to get this concept UI design working in the game:

Concept UI Design

I got the health display just fine. Then I tried to add the orbs in and here's how far I've got it so far:

What I've got

The orbs are getting drawn in the correct place but in the wrong order. The first one getting drawn is the dark red orb and white is the last. I need it to start drawing the first orb (dark red) at the bottom of the health display and then making its way counter-clockwise.

Here's the code:

//Mana UI
for (var i=0; i<5; i++)
{
    draw_sprite(spr_mana_orb, 0, _centerx+28*cos(i*(0.15*pi)), _centery+28*sin(i*(0.15*pi)));
}

As you can guess, I'm lacking math skills.


Solution

  • Using sin for x incrementation and cos for y swaps the axis of the drawing circle, resulting in the style I wanted.

    Like this:

    //Mana UI
    for (var i=0; i<5; i++)
    {
        draw_sprite(spr_mana_orb, 0, _centerx+28*sin(i*(0.15*pi)), _centery+28*cos(i*(0.15*pi)));
    }