undefined

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

AnimModule

Useful for games with a lot of AnimatedSprites overlayed over the rest of the game.

Instead of having the Referee output the entire sequence of images for each new animation, you may have it reference a pre-existing animation as defined in AnimData.js and configured in AnimModule.js.

Example

Referee.java

  // Perform animation labelled "death" starting at t and lasting till end of frame
  double t = 0.2;
  Anim anim = animModule.createAnimationEvent('death', t);
  anim.getParams().put("duration", 1 - t);

AnimModule.js

  anim.started = {frame: number, t: anim.t};
  anim.duration = 
    anim.params.duration // If duration is given, use it
    || 
    DURATIONS[a.id] // Else use predefined duration for this anim id
    || 
    1; // Else animate it for the length of 1 frame
  

⚠ This example might require you modify it for proper use in your own game.

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content