柔体粒子

GameMaker Studio 2 uses the Box2D rigid body physics library, and as such does not permit soft body physics. However the Liquid Fun extension adds particles to the physics system, which permit the creation of simulated soft-bodies using rigid body physics. Basically, you can create a shape of particles that maintain cohesion and so simulate a full body, which, due to the interaction of the particles, gives the impression of a soft body. You can also use the physics particles to simulate liquids and other particle based physics systems.

The following sections are all related to using physics particles to create grioups (soft bodies) and other effects:

Before you start to create your physics particles you will need to set the basic physics properties for them, as you would a fixture in the regular physics. Note though that setting these properties will affect all particles created previously as well as any new particles that you create, so you would normally only use these functions at the start of the game or level. However there are specific functions available to set the particle flags for individual particles (and groups of particles) which will change their properties like "bounciness" or "viscosity", enabling you to create different types of particle within the ranges of these global settings.

The following functions are available for setting and getting global particle system data:

You also have the following functions available for setting flags on individual particles (or groups of particles), as well as for getting information, like position or colour, from a single particle or a single group:


You can create particles in two ways - individually or in groups. Individual particles will behave exactly as defined by the global settings and the flags that were set when they were created, but groups of particles can exhibit different behaviours depending on their group flags. These group flags can be set to different values to give the group different properties, like penetration and rigidity.

The following functions are available for creating particles:


Not only can you create particles, but you can delete them too, either individually or in a region. The following functions are available for deleting particles from the system:


Unless you have activated the debug drawing using physics_draw_debug(), you won't see any particles on the screen when you create them. Therefore to actually see the particles, you need to draw them to the screen in the Draw Event of an instance using the following functions (note that you can also draw them using the regular draw_sprite functions if you get the data for each particle using the functionphysics_particle_get_data):


上一页: 物理
下一页: Physics Variables
© Copyright YoYo Games Ltd. 2018 All Rights Reserved