How to make water pour in GML?

人盡茶涼 提交于 2020-01-06 23:47:56

问题


How can I make water pour from a flask in game maker where have obj_flask , obj_water , and obj_container. I want to make the obj_water pour from obj_flask into the obj_container.


回答1:


This depends hugely on how you want to achieve this effect. You could for example have an animated sprite stretching from the flask to the container. Or you could create water droplet instances at a given time rate and let them be affected by gravity. Or you could use a particle system, but this usually gives you less control if you want to check if it actually hit the container.

I can show you how to make the second idea to get you started.

obj_jug

Step Event:

execute code:

x = mouse_x;
y = mouse_y;
if (mouse_check_button(mb_left))
{
    instance_create(x + 32, y + 8, obj_droplet);
}

obj_droplet

Create Event:

execute code:

a = 1;
v = 0;

Step Event:

execute code:

v += a;
y += v;
if (y >= window_get_height())
{
   instance_destroy();
}

Collision Event with object obj_container:

destroy the instance

This will not give a great effect, but it will do what is being asked.



来源:https://stackoverflow.com/questions/37067422/how-to-make-water-pour-in-gml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!