Begin the creation of a soft body particle group with the given parameters.


physics_particle_group_begin(flags, groupflags, x, y, ang, xv, yv, ang_velocity, col, alpha, strength, category)

参数 描述
flags The flags to set on the particle.
groupflags The group flags to set on the particle (see Description below).
x The x position to create the particle group at.
y The y position to create the particle group at.
ang The angle (in degrees) to rotate the group to on create.
xv The initial horizontal velocity.
yv The initial vertical velocity.
ang_velocity The initial angular velocity.
col The base colour to use for the particle group.
alpha The base alpha to use for the particle group.
strength Set the cohesion strength between particles in the group.
category The user defined category to which the group belongs.

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


With this function you can create a group of particles in a room. A group of particles is one where the particles necessary to create a specific form are created all at once as a group, permitting you to create simulated soft-bodies with various properties set by the flags used. The "flags" are the return value of a combination of the particle constants (see the function physics_particle_create for details of these), while the "groupFlags" are a combination of the following group constants (or 0 for no flags):

常量 描述
phy_particle_group_flag_solid A solid particle group prevents other fixtures from lodging inside of it. Should anything penetrate it, the solid particle group pushes the offending fixture back out to its surface, making a a solid particle group possess an especially strong repulsive force.
phy_particle_group_flag_rigid Rigid particle groups are ones whose shape does not change, even when they collide with other fixtures.

These group flags use bit-masking to create a final output value that is then checked to set the different basic properties of the group, apart from those set by the particle flags. You can use none, one or both of these constants by using the bitwise or "|" to mask the appropriate bits (as shown in the example below).

Other than the flags, you can also set the position in the room to create the particle group at (the position given will be the center of mass of the finished group), the initial horizontal and vertical velocity, as well as the angular velocity of the group, permitting you to create moving, rotating groups.

You can also set initial colour and alpha of all particles in the group, with the values being used when drawing the particles using the function physics_particle_draw(). After that you set the cohesive strength of particles in the group, which is another way of saying how stongly they "stick" to each other. The strength can be a value between 0 and 1, where 0 is no cohesion, and 1 is maximum cohesion.

Finally you have to give the category for your particle group. This value is an arbitrary integer value that you give each particle group that you want to have similar properties, and it can be used to set flags later for that specific category as well as a number of other things.

NOTE: You can use any integer value for the category except 0 which is reserved by the simulation and is used to select all categories in other functions (like for drawing).

It is important to note that calling this function does not create the group in the physics room. This function simply begins the process and sets the base particle properties for the group. To actually create the particle group you need to give it a form (see the example below) and then call the function physics_particle_group_end(), at which point it will be created.

NOTE: The particle type flags that you set will also influence the cohesion of the particle group, such that if you flag the particles as being of the water type (for example), when the group collides with another fixture it will break apart, while if you flag the particle as a spring type, then it will maintain its cohesion on collision.


var flags = phy_particle_flag_water | phy_particle_flag_viscous | phy_particle_flag_tensile;
var groupflags = phy_particle_group_flag_solid | phy_particle_group_flag_rigid;
physics_particle_group_begin(flags, groupflags, mouse_x, mouse_y, 0, 0, 0, 0, c_white, 1, 1, 2);
mLastGroup = physics_particle_group_end();

The above code stores the flags for the particle type and the particle group properties in variables then uses these to create a circular particle group with a 100px radius at the mouse position.

上一页: Soft Body Particles
下一页: physics_particle_group_circle
© Copyright YoYo Games Ltd. 2018 All Rights Reserved