Package: com.multiversesocial.hyperview
Class: com.multiversesocial.hyperview.CollisionAnimGob
Source: src/com/multiversesocial/hyperview/CollisionAnimGob.java
The impact animation CollisionManager shows at the contact point of two COLLIDE_AT_END Gobs. It is an ordinary AnimGob, added to the view’s Gob list and drawn by the display loop. Its 12 frame sprite strip (48 x 48 pixels per frame: a growing, fading fireball with shock ring and sparks) is drawn in code the first time it is needed, because the shipped media has no explosion strip. It plays once over lifeMillis (default 600 ms), then removes itself with remGob().
It never collides: it has no Spline, so collidesAtEnd() is false, and CollisionManager also skips every CollisionAnimGob by class. CollisionManager.collide() calls age() once per display frame to pick the frame for the elapsed time.
Extends: AnimGob
Implements: none directly (AnimGob implements AnimationConstants, HyperConstants)
public class CollisionAnimGob extends AnimGob
| Declaration | Value / initializer | Description | Source |
|---|---|---|---|
long born | System.currentTimeMillis() at creation. | ||
public static final int DEFAULT_MILLIS | = 600 | Time the whole animation takes. | |
Gob first | The two Gobs which collided (first, second); set to null when the animation ends. | ||
public static final int FRAME_SIZE | = 48 | Width and height of one frame. | |
public static final int FRAMES | = 12 | Frames in the strip. | |
int lifeMillis | Length of the animation (a value below 1 given to the constructor becomes DEFAULT_MILLIS). | ||
Gob second | The other Gob (see first). | ||
static BufferedImage strip | Shared by all instances (made once by strip()). |
| Signature | Description | Source |
|---|---|---|
public CollisionAnimGob(HyperView tView, int cx, int cy, int tLifeMillis, Gob a, Gob b) | Impact animation centered on cx,cy (screen pixels). Adds itself to the view’s Gob list (through the in-code image AnimGob constructor). | |
public CollisionAnimGob(HyperView tView, int cx, int cy, int tLifeMillis, Gob a, Gob b, int size) | V3.23: the same, size x size pixels (the explosion of a Gob whose hit points ran out is as big as the Gob). |
| Signature | Description | Source |
|---|---|---|
void age(long nowMillis) | Called by CollisionManager once per display frame: picks the frame for the elapsed time and removes this Gob when the animation is over. HyperView.run draws curClip+1, hence the -1 in the code. | |
public Gob getFirst() | The first Gob of the contact (null once the animation is over). | |
public Gob getSecond() | The second Gob of the contact (null once the animation is over). | |
public int millisLeft() | Milliseconds of animation left (0 when over). | |
static synchronized BufferedImage strip() | The sprite strip: FRAMES frames of FRAME_SIZE x FRAME_SIZE, ARGB, transparent background; each frame is a fireball which grows and fades (white/yellow core, orange, red rim), a thin shock ring and 8 spark rays. Made once. | |
public String toString() | Returns CollisionAnimGob[frame=curClip/totalClips, millisLeft=...]; overrides AnimGob.toString(). |