Package: com.multiversesocial.hyperview
Class: com.multiversesocial.hyperview.CollisionAnimGob
Source: src/com/multiversesocial/hyperview/CollisionAnimGob.java

CollisionAnimGob

HyperView V3.2 — class
version V3.2 class

Summary

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.

Source file: CollisionAnimGob.java

Hierarchy

Extends: AnimGob

Implements: none directly (AnimGob implements AnimationConstants, HyperConstants)

Referenced HyperView classes

Media files used

Declaration & members

public class CollisionAnimGob extends AnimGob

Declared in src/com/multiversesocial/hyperview/CollisionAnimGob.java, lines 1–156. 8 field(s), 2 constructor(s), 6 method(s). Member lists cross-checked against javap -p.

Fields (8)

DeclarationValue / initializerDescriptionSource
long bornSystem.currentTimeMillis() at creation.line 26
public static final int DEFAULT_MILLIS= 600 (constant)Time the whole animation takes.line 22
Gob firstThe two Gobs which collided (first, second); set to null when the animation ends.line 28
public static final int FRAME_SIZE= 48 (constant)Width and height of one frame.line 20
public static final int FRAMES= 12 (constant)Frames in the strip.line 21
int lifeMillisLength of the animation (a value below 1 given to the constructor becomes DEFAULT_MILLIS).line 27
Gob secondThe other Gob (see first).line 29
static BufferedImage stripShared by all instances (made once by strip()).line 24

Constructors (2)

SignatureDescriptionSource
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).line 47
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).line 32

Methods (6)

SignatureDescriptionSource
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.line 65
public Gob getFirst()The first Gob of the contact (null once the animation is over).line 87
public Gob getSecond()The second Gob of the contact (null once the animation is over).line 92
public int millisLeft()Milliseconds of animation left (0 when over).line 81
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.line 102
public String toString()Returns CollisionAnimGob[frame=curClip/totalClips, millisLeft=...]; overrides AnimGob.toString().line 151
Hits--