Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class Collision {
- private static ArrayList<Collision> POOL = new ArrayList<Collision>();
- public GameObject mA;
- public GameObject mB;
- public static Collision init(GameObject a, GameObject b) {
- if (POOL.isEmpty()) {
- return new Collision(a, b); //added to the pool on release
- }
- Collision c = POOL.remove(0);
- c.mA = a;
- c.mB = b;
- return c;
- }
- public static void release(Collision c) {
- c.mA = null;
- c.mB = null;
- POOL.add(c);
- }
- public boolean equals(Collision c) {
- return (mA == c.mA && mB == c.mB) || (mA == c.mB && mB == c.mA);
- }
- public Collision(GameObject a, GameObject b) {
- mA = a;
- mB = b;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement