Hello. This is an example of how one can handle collision between round objects in a 2d coordinate system. It does perfectly elastic collisions, and handles 360 degree collisions and floating point coordinates.
The novel method in this example is that an infinite amount of duplicate objects can be spawned and accounted for. It is usually very difficult to handle cases where 2 duplicate objects are compared to each other in an event condition but need separate actions depending on each object. In MMF, this can be solved in two ways:
1. Spread a value 0 into an Index value of the ball objects. Iterate a nested loop i and i2, where i2 only executes if >i to remove redundant cases. On each i2 execute, plug the values (using 2 separate events to qualify Ball("i") and Ball("i2")) into a holder object. Perform calculations if distance between Ball("i") and Ball("i2") < their combined radii. This is the more complex collision detection, and has an exponential cost per MMF loop the more balls exist on frame.
2. Let MMF handle the collision events using fine detection, and use these red events as a "breaker" sequence. To plug the values of each object in a collision, a secondary value 1 is spread in the CollisionIndex of the qualified balls. Inside the breaker sequence, we can plug the values into our holder object and perform the vector calculations before putting the result back into our 2 collided balls. This method is what is used in our example.
Calculating the vectors themselves is done using a relatively common method. In our example, X and Y deltas are used to change the balls' positions on each display loop. When a ball collides with a rigid body, itself, or the delta forces otherwise change, a new vector is calculated by converting the delta values into polar coordinates. In the ball-to-ball collision method, we operate on these polar coordinates before converting them back to the delta values (which are used for the practical movement).
The primary advantage to this example is that no non-clickteam extensions are used in it. Because of this, it should be portable to any platform which MMF's export can support. I've also added a shader to this example to give an idea of what you can do with the duplicate objects. Once the method is understood, the complexity of the code is reduced considerably, and can be expanded/reused to fit the developer's needs.
Feel free to let me know if you found this example useful.