Animation: implement necessary bits for normalForm()
This allows a layered image to specify an animation as one of its layers, and for it to still be recognized as an animation after being processed by MakeTiles.
This commit is contained in:
parent
d9761ec54f
commit
bf0c33fbe9
2 changed files with 33 additions and 2 deletions
|
@ -182,6 +182,8 @@ public class MakeTiles
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ref = ref.normalForm();
|
||||||
|
|
||||||
TileImage dest = prepareFrames(ref, c);
|
TileImage dest = prepareFrames(ref, c);
|
||||||
TileMapping m = new TileMapping(tileName, ref, dest);
|
TileMapping m = new TileMapping(tileName, ref, dest);
|
||||||
mappings.add(m);
|
mappings.add(m);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.*;
|
||||||
import javax.xml.stream.*;
|
import javax.xml.stream.*;
|
||||||
import static micropolisj.XML_Helper.*;
|
import static micropolisj.XML_Helper.*;
|
||||||
|
|
||||||
public class Animation extends TileImage
|
public class Animation extends TileImage implements TileImage.MultiPart
|
||||||
{
|
{
|
||||||
static final int DEFAULT_DURATION = 125;
|
static final int DEFAULT_DURATION = 125;
|
||||||
|
|
||||||
|
@ -52,6 +52,30 @@ public class Animation extends TileImage
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//implements MultiPart
|
||||||
|
public MultiPart makeEmptyCopy()
|
||||||
|
{
|
||||||
|
return new Animation();
|
||||||
|
}
|
||||||
|
|
||||||
|
//implements MultiPart
|
||||||
|
public Iterable<? extends Part> parts()
|
||||||
|
{
|
||||||
|
return frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
//implements MultiPart
|
||||||
|
public void addPartLike(TileImage image, Part refPart)
|
||||||
|
{
|
||||||
|
addFrame(image, ((Frame)refPart).duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
//implements MultiPart
|
||||||
|
public TileImage asTileImage()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public void addFrame(TileImage img, int duration)
|
public void addFrame(TileImage img, int duration)
|
||||||
{
|
{
|
||||||
totalDuration += duration;
|
totalDuration += duration;
|
||||||
|
@ -98,7 +122,7 @@ public class Animation extends TileImage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Frame
|
public class Frame implements Part
|
||||||
{
|
{
|
||||||
public final TileImage frame;
|
public final TileImage frame;
|
||||||
public final int duration;
|
public final int duration;
|
||||||
|
@ -108,6 +132,11 @@ public class Animation extends TileImage
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//implements TileImage.Part
|
||||||
|
public TileImage getImage() {
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TileImage getDefaultImage()
|
private TileImage getDefaultImage()
|
||||||
|
|
Reference in a new issue