简体   繁体   English

如何自动创建精灵并将其在房间中垂直移动? GameMaker开发人员

[英]How to auto-create the sprite and move them vertically in the room? GameMaker developer

Guys I want to do this without GML I guess it's enter image description here easy to do it. 伙计们,我想在没有GML的情况下执行此操作,我想这是在此处轻松输入图像描述的方法 You can see in the image I have uploaded. 您可以在我上传的图像中看到。 there are three sprites and I want them to enter the room randomly at specific location. 有三个子画面,我希望它们在特定位置随机进入房间。

Guys I'm new to game maker this is my first game. 伙计们,我是游戏开发商的新手,这是我的第一场比赛。

I'm making a shooting game for Android. 我正在为Android开发射击游戏。 You can refer the image for clear idea about the game. 您可以参考该图像以获取有关游戏的清晰思路。 Things I did are: I made 3 sprite red, yellow, green 我所做的是:我制作了3个精灵红色,黄色,绿色

What I want to do is: I want the red yellow green sprite moving in vertically and the player gonna shoot them. 我想做的是:我希望红色,黄色,绿色的精灵垂直移动,而玩家要射击它们。

I want the sprite to get created automatically at random location(at the top I mean) and move in vertical direction and should not overlap each other. 我想让子画面自动在随机位置创建(在顶部,我指的是)并沿垂直方向移动,并且彼此之间不应重叠。

How should I do it? 我该怎么办?

Well, there's a lot of different way to do this. 好吧,有很多不同的方法可以做到这一点。 The simplest one is to create an object, assign it a sprite, spawn it at a random y and assign it a vspeed. 最简单的方法是创建一个对象,为其指定一个精灵,以随机y生成它,并为其赋予vspeed。

in the object create event : 在对象创建事件中:

sprite_index = your_sprite;
x = 0;
y = random(room_width);
vspeed = the_speed_you_want;

I suppose you want to be able to shoot at the sprites, so it is better to make an object than to simply draw them. 我想你想能够射击小精灵,所以制作一个物体比简单绘制它们更好。 If you don't want them to overlap, you can define 3 possible starting positions and randomly chose one with the choose() function. 如果您不希望它们重叠,则可以定义3个可能的起始位置,并使用choice()函数随机选择一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM