Back
Close

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.

Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants