mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-09 10:28:25 +07:00
Added support for reversing Animation direction
This commit is contained in:
parent
1781e46724
commit
3906fbdf4c
@ -1,5 +1,8 @@
|
||||
package com.riiablo.codec;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
@ -13,15 +16,12 @@ import com.badlogic.gdx.utils.Bits;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.badlogic.gdx.utils.Pool;
|
||||
import com.badlogic.gdx.utils.Pools;
|
||||
|
||||
import com.riiablo.Riiablo;
|
||||
import com.riiablo.codec.util.BBox;
|
||||
import com.riiablo.graphics.BlendMode;
|
||||
import com.riiablo.graphics.PaletteIndexedBatch;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Animation extends BaseDrawable implements Pool.Poolable {
|
||||
private static final String TAG = "Animation";
|
||||
private static final int DEBUG_MODE = 1; // 0=off, 1=box, 2=layer box
|
||||
@ -49,6 +49,8 @@ public class Animation extends BaseDrawable implements Pool.Poolable {
|
||||
public enum Mode { ONCE, LOOP, CLAMP }
|
||||
Mode mode = Mode.LOOP;
|
||||
|
||||
boolean reversed;
|
||||
|
||||
boolean highlighted;
|
||||
|
||||
final Layer layers[] = new Layer[NUM_LAYERS];
|
||||
@ -80,6 +82,7 @@ public class Animation extends BaseDrawable implements Pool.Poolable {
|
||||
startIndex = 0;
|
||||
endIndex = 0;
|
||||
mode = Mode.LOOP;
|
||||
reversed = false;
|
||||
frameDuration = FRAME_DURATION;
|
||||
highlighted = false;
|
||||
Layer.freeAll(layers);
|
||||
@ -186,6 +189,14 @@ public class Animation extends BaseDrawable implements Pool.Poolable {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public boolean isReversed() {
|
||||
return reversed;
|
||||
}
|
||||
|
||||
public void setReversed(boolean b) {
|
||||
reversed = b;
|
||||
}
|
||||
|
||||
public boolean isHighlighted() {
|
||||
return highlighted;
|
||||
}
|
||||
@ -367,6 +378,7 @@ public class Animation extends BaseDrawable implements Pool.Poolable {
|
||||
public void update(float delta) {
|
||||
elapsedTime += delta;
|
||||
frame = getFrame(elapsedTime);
|
||||
if (reversed) frame = endIndex - 1 - frame;
|
||||
notifyListeners(frame);
|
||||
if (frame == endIndex - 1) notifyAnimationFinished();
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
import com.riiablo.Riiablo;
|
||||
import com.riiablo.codec.Animation;
|
||||
import com.riiablo.codec.DC6;
|
||||
@ -31,7 +32,7 @@ public class EscapePanel extends WidgetGroup implements Disposable {
|
||||
EscapeButton returntogame;
|
||||
|
||||
final AssetDescriptor<DC6> pentspinDescriptor = new AssetDescriptor<>("data\\global\\ui\\CURSOR\\pentspin.DC6", DC6.class);
|
||||
Animation pentspin;
|
||||
Animation pentspinL, pentspin;
|
||||
FocusActor[] focusActor;
|
||||
|
||||
public EscapePanel() {
|
||||
@ -69,10 +70,13 @@ public class EscapePanel extends WidgetGroup implements Disposable {
|
||||
|
||||
Riiablo.assets.load(pentspinDescriptor);
|
||||
Riiablo.assets.finishLoadingAsset(pentspinDescriptor);
|
||||
pentspinL = Animation.newAnimation(Riiablo.assets.get(pentspinDescriptor));
|
||||
pentspinL.setReversed(true);
|
||||
pentspin = Animation.newAnimation(Riiablo.assets.get(pentspinDescriptor));
|
||||
focusActor = new FocusActor[6];
|
||||
for (int i = 0; i < focusActor.length; i++) {
|
||||
focusActor[i] = new FocusActor(pentspin);
|
||||
for (int i = 0; i < focusActor.length; i += 2) {
|
||||
focusActor[i ] = new FocusActor(pentspinL);
|
||||
focusActor[i + 1] = new FocusActor(pentspin);
|
||||
}
|
||||
ClickListener focusListener = new ClickListener() {
|
||||
@Override
|
||||
@ -136,6 +140,7 @@ public class EscapePanel extends WidgetGroup implements Disposable {
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float a) {
|
||||
pentspinL.act();
|
||||
pentspin.act();
|
||||
super.draw(batch, a);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user