package com.margenta.android.framework.motion;
import com.margenta.android.framework.node.MNode;
public class Movement implements Motional {
public Motion motion;
public MNode target;
public Movement(Motion mother, MNode node) {
this.motion = mother;
this.target = node;
}
public void change(int behaviorCnt) {
boolean isDone = false;
int runningCnt = behaviorCnt - motion.delayFrame;
if(runningCnt >= 0){
if(runningCnt >= motion.endCnt){
if(motion.endCnt >= 0){
isDone = true;
runningCnt = motion.endCnt - 1;
}
}
int applyCnt = 0;
if(motion.bReverse){
applyCnt = runningCnt % (motion.durationFrame * 2 - 1);
if(applyCnt >= motion.durationFrame)
applyCnt = (motion.durationFrame * 2 - 2) - applyCnt;
}else{
applyCnt = runningCnt % motion.durationFrame;
if(motion.bEndBack && isDone)
applyCnt = 0;
}
if(applyCnt >= motion.arrVals.length){
applyCnt = motion.arrVals.length-1;
}
apply(applyCnt);
}
}
public void applyFirst() {
motion.apply(target, 0);
}
public void applyEnd() {
motion.apply(target, motion.arrVals.length - 1);
}
private void apply(int frameIndex){
motion.apply(target, frameIndex);
}
}
|