在GMS2中如何在弧形模式上绘制精灵?

huangapple go评论49阅读模式
英文:

How to draw sprites on an arc pattern in GMS2?

问题

我一直在尝试在游戏中使这个概念UI设计工作:

概念UI设计

我成功地显示了生命值。然后我尝试添加宝珠,目前的进展如下:

我所拥有的

宝珠被绘制在正确的位置,但顺序错误。第一个被绘制的是深红色宝珠白色是最后一个。我需要从底部开始绘制第一个宝珠(深红色),然后逆时针绘制它们。

以下是代码:

//法力值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)));
}

正如你所猜测的,我在数学方面缺乏技能。

英文:

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.

答案1

得分: 0

使用sin函数来增加x值,使用cos函数来交换y值会改变绘制圆的坐标轴,从而得到我想要的风格。

像这样:

//魔法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)));
}
英文:

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&lt;5; i++)
{
    draw_sprite(spr_mana_orb, 0, _centerx+28*sin(i*(0.15*pi)), _centery+28*cos(i*(0.15*pi)));
}

huangapple
  • 本文由 发表于 2023年6月22日 01:55:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76525973.html
  • game-maker-language
  • game-maker-studio-2
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定