Sets the shape of created particles to a sprite.


part_type_sprite(ind, sprite, animate, stretch, random);

参数 描述
ind The index of the particle type to change.
sprite The index of the sprite to set the particle type to.
animate Whether to follow the sprite's animation normally (true) or not (false).
stretch Whether to stretch the sprite's animation to match the particle lifespan (true) or not (false).
random Whether to choose a random sub-image (true) or not (false).

返回: N/A(无返回值)


This function can be used to set a particle type to use a custom sprite from the game assets. You can select the sprite and then tell GameMaker Studio 2 to use the sprite and animate it or not, and if you choose animated, then you can also choose to have the sub-images changed at an interval such that the animation will begin and end at the beginning and end of the lifetime of each particle created (so that if you have a lifetime set to a15 step minimum and a 30 step maximum, no matter what value the lifetime has the animation will be made to fit, with it running faster for the shorter lifetimes and slower for the longer). You can also select to choose a random sub-image so that if the sprite is not animated, a different image will be chosen at random to create the sprite, or if the particle is animated it will start the animation at a random point.


global.p1 = part_type_create();
part_type_sprite(global.p1 , spr_Coins, 1, 0, 0);
part_type_size(global.p1, 1, 3, 0, 0);
part_type_scale(global.p1, 1, 1);
part_type_colour1(global.p1, c_white);
part_type_alpha2(global.p1, 1, 0);
part_type_speed(global.p1, 2, 4, 0, 0);
part_type_direction(global.p1, 0, 180, 0, 0);
part_type_gravity(global.p1, 0.20, 270);
part_type_orientation(global.p1, 0, 0, 0, 0, 1);
part_type_blend(global.p1, 1);
part_type_life(global.p1, 15, 60);

The above code sets the particle type indexed in the global variable "p1" to the shape of the sprite indexed in "spr_Coins", and then sets various other particle properties.

上一页: Particle Types
下一页: part_type_size
© Copyright YoYo Games Ltd. 2018 All Rights Reserved