Skip to content

Commit db7ae82

Browse files
committed
fix bug in folder names
1 parent bb5e7ac commit db7ae82

File tree

99 files changed

+11423
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+11423
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.lfk.justweengine.anim;
2+
3+
import com.lfk.justweengine.engine.GameTimer;
4+
5+
/**
6+
* 判断生死
7+
*
8+
* @author liufengkai
9+
* Created by liufengkai on 15/12/5.
10+
*/
11+
public class AliveAnimation extends BaseAnim {
12+
private int liftTime;
13+
private GameTimer timer;
14+
15+
public AliveAnimation(int liftTime) {
16+
this.liftTime = liftTime;
17+
this.timer = new GameTimer();
18+
animating = true;
19+
animType = AnimType.ALIVE;
20+
}
21+
22+
@Override
23+
public boolean adjustAlive(boolean ori) {
24+
if (liftTime > 0 && timer.stopWatch(liftTime)) {
25+
ori = false;
26+
}
27+
return ori;
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.lfk.justweengine.anim;
2+
3+
/**
4+
* 透明度动画
5+
*
6+
* @author liufengkai
7+
* Created by liufengkai on 15/11/28.
8+
*/
9+
public class AlphaAnimation extends BaseAnim {
10+
private int maxAlpha;
11+
private int minAlpha;
12+
private int changeAlpha;
13+
14+
public AlphaAnimation(int changeAlpha) {
15+
this(255, 0, changeAlpha);
16+
}
17+
18+
public AlphaAnimation(int maxAlpha, int minAlpha, int changeAlpha) {
19+
super();
20+
this.maxAlpha = maxAlpha;
21+
this.minAlpha = minAlpha;
22+
this.changeAlpha = changeAlpha;
23+
this.animType = AnimType.ALPHA;
24+
this.animating = true;
25+
}
26+
27+
@Override
28+
public int adjustAlpha(int ori) {
29+
int modified = ori;
30+
modified += changeAlpha;
31+
if (modified < minAlpha) {
32+
modified = minAlpha;
33+
animating = false;
34+
}
35+
if (modified > maxAlpha) {
36+
modified = maxAlpha;
37+
animating = false;
38+
}
39+
return modified;
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.lfk.justweengine.anim;
2+
3+
/**
4+
* 动画类型
5+
*
6+
* @author liufengkai
7+
* Created by liufengkai on 15/11/28.
8+
*/
9+
public enum AnimType {
10+
// anim with frame change
11+
FRAME,
12+
13+
ALPHA,
14+
15+
SCALE,
16+
17+
ROTATION,
18+
19+
POSITION,
20+
21+
WRAPMOVE,
22+
23+
ALIVE,
24+
25+
SHOOT,
26+
27+
ZOOM,
28+
29+
ZOOM_CENTER,
30+
31+
MASK,
32+
33+
COLOR,
34+
35+
NULL
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.lfk.justweengine.anim;
2+
3+
import android.graphics.Rect;
4+
import android.renderscript.Float2;
5+
6+
/**
7+
* 动画基类
8+
*
9+
* @author liufengkai
10+
* Created by liufengkai on 15/11/28.
11+
*/
12+
public class BaseAnim {
13+
// Is it running ?
14+
public boolean animating;
15+
// anim type
16+
public AnimType animType;
17+
18+
// init
19+
public BaseAnim() {
20+
animating = false;
21+
animType = AnimType.NULL;
22+
}
23+
24+
public int adjustAlpha(int ori) {
25+
return ori;
26+
}
27+
28+
public int adjustFrame(int ori) {
29+
return ori;
30+
}
31+
32+
public Float2 adjustScale(Float2 ori) {
33+
return ori;
34+
}
35+
36+
public float adjustRotation(float ori) {
37+
return ori;
38+
}
39+
40+
public Float2 adjustPosition(Float2 ori) {
41+
return ori;
42+
}
43+
44+
public boolean adjustAlive(boolean ori) {
45+
return ori;
46+
}
47+
48+
public Rect adjustScale(Rect ori) {
49+
return ori;
50+
}
51+
52+
public float adjustTag(float ori) {
53+
return ori;
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.lfk.justweengine.anim;
2+
3+
import android.graphics.Point;
4+
import android.renderscript.Float2;
5+
6+
/**
7+
* Created by liufengkai on 15/11/29.
8+
*/
9+
public class CircleMoveAnimation extends BaseAnim {
10+
private int radius;
11+
private Point center;
12+
private double angle;
13+
private float velocity;
14+
15+
public CircleMoveAnimation(int centerX, int centerY,
16+
int radius, double angle,
17+
float velocity) {
18+
animating = true;
19+
animType = AnimType.POSITION;
20+
this.center = new Point(centerX, centerY);
21+
this.radius = radius;
22+
this.angle = angle;
23+
this.velocity = velocity;
24+
}
25+
26+
@Override
27+
public Float2 adjustPosition(Float2 ori) {
28+
angle += velocity;
29+
ori.x = (int) (center.x + (float) (Math.cos(angle) * radius));
30+
ori.y = (int) (center.y + (float) (Math.sin(angle) * radius));
31+
return ori;
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.lfk.justweengine.anim;
2+
3+
/**
4+
* Created by liufengkai on 15/12/2.
5+
*/
6+
public interface DoAfterAnimation {
7+
void afterAnimation();
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.lfk.justweengine.anim;
2+
3+
import android.graphics.Rect;
4+
import android.renderscript.Float2;
5+
6+
/**
7+
* 围栏使用动画防止出界
8+
*
9+
* @author liufengkai
10+
* Created by liufengkai on 15/12/4.
11+
*/
12+
public class FenceAnimation extends BaseAnim {
13+
private Rect fence;
14+
15+
public FenceAnimation(Rect fence) {
16+
this.fence = fence;
17+
animating = true;
18+
animType = AnimType.POSITION;
19+
}
20+
21+
@Override
22+
public Float2 adjustPosition(Float2 ori) {
23+
if (ori.x < fence.left)
24+
ori.x = fence.left;
25+
else if (ori.x > fence.right)
26+
ori.x = fence.right;
27+
else if (ori.y < fence.top)
28+
ori.y = fence.top;
29+
else if (ori.y > fence.bottom)
30+
ori.y = fence.bottom;
31+
return ori;
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.lfk.justweengine.anim;
2+
3+
import com.lfk.justweengine.engine.GameTimer;
4+
5+
/**
6+
* 逐帧动画
7+
*
8+
* @author liufengkai
9+
* Created by liufengkai on 15/11/29.
10+
*/
11+
public class FrameAnimation extends BaseAnim {
12+
private int firstFrame;
13+
private int lastFrame;
14+
private int direction;
15+
private int interval;
16+
// 帧动画切换时间间隔,单位ms
17+
private GameTimer timer;
18+
19+
public FrameAnimation(int firstFrame, int lastFrame, int direction) {
20+
this.firstFrame = firstFrame;
21+
this.lastFrame = lastFrame;
22+
this.direction = direction;
23+
this.animType = AnimType.FRAME;
24+
this.animating = true;
25+
this.interval = 0;
26+
timer = new GameTimer();
27+
}
28+
29+
public FrameAnimation(int firstFrame, int lastFrame, int direction, int interval) {
30+
this.firstFrame = firstFrame;
31+
this.lastFrame = lastFrame;
32+
this.direction = direction;
33+
this.animType = AnimType.FRAME;
34+
this.animating = true;
35+
this.interval = interval;
36+
timer = new GameTimer();
37+
}
38+
39+
@Override
40+
public int adjustFrame(int ori) {
41+
int modified = ori;
42+
if (timer.stopWatch(interval)) {
43+
modified += direction;
44+
if (modified < firstFrame) {
45+
modified = lastFrame;
46+
} else if (modified > lastFrame) {
47+
modified = firstFrame;
48+
}
49+
}
50+
return modified;
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.lfk.justweengine.anim;
2+
3+
import android.renderscript.Float2;
4+
import android.util.Log;
5+
6+
/**
7+
* Created by liufengkai on 15/12/3.
8+
*/
9+
public class MoveAnimation extends BaseAnim {
10+
private Float2 velocity;
11+
private float toX;
12+
private float toY;
13+
14+
public MoveAnimation(
15+
float toX, float toY,
16+
Float2 velocity) {
17+
this.toX = toX;
18+
this.toY = toY;
19+
this.velocity = velocity;
20+
animating = true;
21+
animType = AnimType.POSITION;
22+
}
23+
24+
@Override
25+
public Float2 adjustPosition(Float2 ori) {
26+
if (ori.x != toX) {
27+
if (ori.x > toX)
28+
ori.x -= velocity.x;
29+
else
30+
ori.x += velocity.x;
31+
}
32+
if (ori.y != toY) {
33+
Log.d("ori.y" + ori.y, "toY" + toY);
34+
if (ori.y > toY)
35+
ori.y -= velocity.y;
36+
else
37+
ori.y += velocity.y;
38+
}
39+
if (Math.abs(ori.x - toX) < velocity.x &&
40+
Math.abs(ori.y - toY) < velocity.y) {
41+
animating = false;
42+
}
43+
return ori;
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.lfk.justweengine.anim;
2+
3+
import android.renderscript.Float2;
4+
5+
import com.lfk.justweengine.info.UIdefaultData;
6+
7+
/**
8+
* Created by liufengkai on 15/12/5.
9+
*/
10+
public class ShootAnimation extends BaseAnim {
11+
private float speed;
12+
private float y;
13+
14+
public ShootAnimation(float y, float v) {
15+
this.speed = v;
16+
this.y = y;
17+
animating = true;
18+
animType = AnimType.SHOOT;
19+
}
20+
21+
@Override
22+
public Float2 adjustPosition(Float2 original) {
23+
y = original.y += speed;
24+
return original;
25+
}
26+
27+
@Override
28+
public boolean adjustAlive(boolean ori) {
29+
if (y < 0 || y > UIdefaultData.screenHeight) {
30+
ori = false;
31+
}
32+
return ori;
33+
}
34+
}

0 commit comments

Comments
 (0)