英文:
How to draw sprites on an arc pattern in GMS2?
问题
我一直在尝试在游戏中使这个概念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:
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:
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<5; i++)
{
draw_sprite(spr_mana_orb, 0, _centerx+28*sin(i*(0.15*pi)), _centery+28*cos(i*(0.15*pi)));
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论