On Thu, May 3, 2012 at 12:25 PM, Neil Voskeritchian
<
nvosker...@gmail.com> wrote:
> Before I was able to just repeatedly call setSourceRect on the image that
> the ImageLayer already contained. Is this by design? Now I have to call
> imageLayer.setImage(image.subImage(x,y, width,height)) on every frame
> update I want animation to take place.
I recently added Image.Region.setBounds() for exactly this use case. I
haven't merged those changes upstream, I'll do that now. The
SubImageTest in playn/tests demonstrates the use of this API:
private float elapsed;
private Image.Region osci;
public void init() {
Image orange = assets().getImage("images/orange.png");
osci = orange.subImage(0, 0, orange.width(), orange.height());
graphics().rootLayer().addAt(graphics().createImageLayer(osci), 150, 300);
}
public void update(float delta) {
elapsed += delta;
float osciCurWidth = Math.abs(FloatMath.sin(elapsed/1000)) *
osci.parent().width();
osci.setBounds(0, 0, osciCurWidth, osci.parent().height());
}
--
m...@samskivert.com